Issue
I am a newbie to Python attempting to experiment with sample code under Windows 8.1.
On http://flask.pocoo.org/docs/0.10/quickstart/ it says "if you enable debug support the server will reload itself on code changes, and it will also provide you with a helpful debugger".
I have added to the code app.run(debug=True)
to the sample code on the above page. The server will now reload itself on code changes (as promised) but when I create a syntax error the "helpful debugger" does not show. Instead I get an error message in my command prompt.
Any ideas why? I suspect the answer might be here Can't enable debug mode in Flask but it is largely uninteligible to me.
So far I have tried restarting my machine and putting the code in different locations. I am not in a forked environment (as best as I know). For those that are curious my source code is shown below:
from flask import Flask
app = Flask(__name__)
from werkzeug.debug import DebuggedApplication
app.wsgi_app = DebuggedApplication(app.wsgi_app, True)
@app.route('/')
def hello_world():
return 'Hello World! #note the deliberate syntax error
if __name__ == '__main__':
app.debug = True
app.run()
Solution
The debugger is for debugging exceptions in a syntactically valid program. Try raising an exception in your code, visit the URL in a browser window, and you will see the very helpful debugger. See also http://flask.pocoo.org/snippets/21/
Syntax errors will be shown on the console as you have seen. That's how it works.
Answered By - bsa
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.