Following this wonderful article, I’m trying to use the IPython REPL for debugging my Flask app. The idea is that you run
import IPython; IPython.embed() at a point where you want to take a look around the state of your projects.
I’m developing my app in a Docker container to make it easier to run with other services. I tried inserting this line into a views.py function like so:
@page.route('/', methods=['GET', 'POST']) def index(): form = SearchForm() if form.validate_on_submit(): results = request.form.get('search') import IPython; IPython.embed() return render_template('page/index.html', form=form, results=results) else: flash(form.errors) return render_template('page/index.html', form=form)
When a valid POST request is made through the form, I see the following output from Docker:
website_1 | IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help. website_1 | In : Do you really want to exit ([y]/n)?
Then I see gunicorn logging the POST and GET requests. It would seem docker automatically shuts down IPython and continues to render_template.
I’m wondering if there is anyway to get this to work as an actual breakpoint as described in the article. I’d love to be able to take a look around my code this way. Thanks in advance for any advice.