Skip to content

Instantly share code, notes, and snippets.

@hughdbrown
Created October 1, 2018 22:20
Show Gist options
  • Save hughdbrown/1d7aba9784fe7ae74e652a8aa6f710a1 to your computer and use it in GitHub Desktop.
Save hughdbrown/1d7aba9784fe7ae74e652a8aa6f710a1 to your computer and use it in GitHub Desktop.
Notes on how flask request paramets map to an HTTP request
from flask import request
request.view_args
@app.route("/data/<section>")
def data(section):
assert section == request.view_args['section']
For URL Query parameter, use request.args
search = request.args.get("search")
page = request.args.get("page")
For Form input, use request.form
email = request.form.get('email')
password = request.form.get('password')
For data type application/json, use request.data
# data in string format and you have to parse into dictionary
data = request.data
dataDict = json.loads(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment