r/flask • • Sep 30 '26

Ask r/Flask Debugging flask app.py

With .cgi frameworks, I can run an app and give it arguments on the command line, and then use python -mpdb to step through and see what is happening (and going wrong).

I have a flask app that is working, but not always working properly. So it does not crash, but it does not do what I expect.

I would like to be able to run: python3 -mpdb app.py

set a break point, and have the code stop at that breakpoint. I can set the breakpoint, but the code seems to ignore it, so I cannot single step through the program to see what is wrong. My app.py main() looks like:

if __name__ == "__main__":
      app.run(debug=True, use_reloader=False)

How can I debug my program using python3 -mpdb?

2 Upvotes

3 comments sorted by

View all comments

1

u/CursleyMidhi90 Oct 09 '26

you also want `use_debugger=False` alongside `use_reloader=False`, otherwise the built-in debugger can interfere with pdb. then stick a `breakpoint()` call directly in the view you're testing