Skip to content

Instantly share code, notes, and snippets.

@navinpai
Created January 3, 2012 19:03
Show Gist options
  • Select an option

  • Save navinpai/1556353 to your computer and use it in GitHub Desktop.

Select an option

Save navinpai/1556353 to your computer and use it in GitHub Desktop.
Form Processing with Flask
#From http://flask.pocoo.org/docs/quickstart/
from flask import request
@app.route('/login', methods=['POST', 'GET'])
def login():
error = None
if request.method == 'POST':
if valid_login(request.form['username'],
request.form['password']):
return log_the_user_in(request.form['username'])
else:
error = 'Invalid username/password'
# this is executed if the request method was GET or the
# credentials were invalid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment