Python: Using pdb with Flask application

flask, pdb, python

Solution

This is because you're using Foreman, which captures the standard output.

To debug your app with `pdb`, you'll need to "manually" run it, using `python app.py` or whatever you use.

Alternatively, you can use WinPDB (which, despite the name, has nothing to do with the operating system), which will let you remotely debug a Python process. You can even use it when the program is running on another server.

Problem

I'm using Flask 0.9 with Python 2.7.1 within a virtualenv, and starting my app with `foreman start` In other apps I've built when I add the following line to my app: ``` import pdb; pdb.set_trace() ``` then reload the browser window, my terminal window displays the pdb interactive debugger: ``` (pdb) ``` However in my app when I add those lines nothing happens. The browser window hangs and shows a constant state of loading yet nothing shows in the console. Is there some magic that needs to happen?

Original source