Skip to content

Instantly share code, notes, and snippets.

@kgriffs
Created July 24, 2019 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgriffs/7db18102a2051cfaa60503638d3af673 to your computer and use it in GitHub Desktop.
Save kgriffs/7db18102a2051cfaa60503638d3af673 to your computer and use it in GitHub Desktop.
Falcon: Multipart form parsing example
import cgi
# NOTE: This does not handle file uploads
def parse_form(req):
# NOTE: See also the docs for cgi.FieldStorage
form = cgi.FieldStorage(fp=req.stream, environ=req.env,
keep_blank_values=1)
if not form.list:
return {}
# NOTE(kgriffs): This assumes you are not expecting duplicate fields
# with the same name.
return {field.name: field.value for field in form.list}
@oldman1991
Copy link

thanks for your idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment