Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python and POST data

Tags:

python

http

post

In PHP I simply write:

$bob = $_POST['bob'];

How do I do the same in Python?

And yes, I do normally check that it exists etc, I'm just stripping it down specifically to the functionality I am after.


Edit: I am not using a framework
like image 430
Teifion Avatar asked Sep 22 '08 19:09

Teifion


1 Answers

The simplest method is the 'cgi' module:

import cgi
data = cgi.FieldStorage()
data['bob']

But the context you are executing in (frameworks you're using, WSGI or even (heaven forbid) mod_python) may have different, more efficient or more direct methods of access.

like image 127
Thomas Wouters Avatar answered Oct 06 '22 09:10

Thomas Wouters