Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Welcome to Flask First Steps

Want to use Flask under Windows 8 from command line

Does anyone know how to make this code run from the Windows command line?

from flask import Flask
from flask import request

app = Flask(__name__)

def index(name="Treehouse"):
#if we get a name, use it, if not use Treehouse as the default
    name = request.args.get('name', name)
    return "Hello from {}".format(name)

app.run(debug=True, port=8000, host='')

3 Answers

William Li
William Li
Courses Plus Student 26,868 Points

Hi, Joni Carlson

I suggest you check out this course Setting Up a Local Python Environment, it walks you through how to setup Python environment on your local machine (Windows included).


Another good option is cygwin which allows you to have a Linux-like functionality within the Windows-OS. It's not a panacea, but it can help a developer work within Windows!

First you need to add python to your PATH.

There is an answer about it http://stackoverflow.com/questions/6318156/adding-python-path-on-windows-7

Second, Open terminal in windows.

To do it press CTRL + R, type cmd and hit Enter

Go to folder which contains your python script.

You can do this by typing


For example if your script is in your Documents folder,

cd C:\Users\BlaBla\Documents

Write command python your_script_name.py and hit Enter. If you are using python 3 or above use python -3 your_script_name.py instead.

Use CTRL + C to kill your program.