Python Flask Basics Character Builder Forms

Flask 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                                                             
 * Running on (Press CTRL+C to quit)                                          
 * Restarting with stat                                                                            
 * Debugger is active!                                                                             
 * Debugger PIN: 198-582-598                                                                       
> /home/treehouse/workspace/                                                       
-> 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

12,964 Points

Hi 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! :)