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 Clean URL Arguments

Have to relaunch the program after changing code.

from flask import Flask

app = Flask(__name__)


@app.route('/')
@app.route('/<name>')
def index(name="Treehouse"):
    return "Hello from {}".format(name)

@app.route('/add/<int:num1>/<int:num2>')
def add(num1, num2):
    return '{} + {} = {}'.format(num1, num2, num1+num2)

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

Using the code above. debug is set to True. I'm finding that in addition to saving the program, I have to relaunch it in the console, otherwise the port8000 view redirects me to the same webpage as the one coming from older version. Pls tell me what I may be doing wrong. Thanks.

2 Answers

Try this in the terminal:

$ export FLASK_ENV=development
$ flask run

http://flask.pocoo.org/docs/1.0/quickstart/#debug-mode

Thank you for the info,

so, I'm able to pass export FLASK_ENV=development but I get an error on the next bit, which is flask run:

bash: flask: command not found.

Now i'm not sure if this has something to do with the fact that this is being run on workspaces on treehouse servers.