Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialalenwong
4,346 PointsFlask Basic - Forms - view request in pdb
Hi all
I am trying to put code starting from 5:30 in video Flask Basic - Forms to the workspace. More specifically - import pdb; pdb.set_trace() under the save() view/function
@app.route('/save', methods=['POST']) #only accessible via POST
def save():
import pdb; pdb.set_trace()
return redirect(url_for('index'))
Then I press the submit button and pdb invoked in the workspace console as expected. However, when I put "request.form" given the pdb prompt (as shown @6:15), I got an name error.
treehouse:~/workspace$ python app.py
* Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 198-582-598
> /home/treehouse/workspace/app.py(15)save()
-> return redirect(url_for('index'))
(Pdb) dir(request)
*** NameError: name 'request' is not defined
(Pdb) reqeust.form
*** NameError: name 'reqeust' is not defined
Not sure if someone can help? Thanks.
1 Answer
nakalkucing
12,964 PointsHi Alen Wong! I know it's been awhile since you asked this. :) But did you import request at the top of your page?
from flask import Flask, render_template, redirect, url_for, request
Happy coding! :)