How do you debug url routing in Flask? How do you debug url routing in Flask? flask flask

How do you debug url routing in Flask?


For the Flask debugger, you can set app.debug to True:

app.debug = True

or

app.run(debug=True)

And then:

@app.route('/')def index():   raise   return render_template('index.html') 

And then you can debug the function with the Flask debugger in your browser.


6 months later, and while it still doesn't look possible to automatically debug URL routing in flask, you can manually attach a debugger to the flask process, though you'll have to re-add it if you restart the server or if the auto-reloader detects changes in your .py files and restarts.

Just go:Tools -> Attach to Processand select the Python.exe that is not greyed out (that's the initial flask code that visual studio is already debugging), and then do something that would cause the breakpoint to be hit (e.g. reload the page), and you should have success.


Sadly the current version of PTVS doesn't support Flask projects.

Good thing is: the already released PTVS 2.1 alpha does: http://pytools.codeplex.com/wikipage?title=Flask