How are POST and GET variables handled in Python?
Question: In PHP you can just use `$_POST` for POST and `$_GET` for GET (Query string)
variables. What's the equivalent in Python?


Answer: suppose you're posting a html form with this:

    
    
    <input type="text" name="username">
    

If using [raw cgi](http://docs.python.org/library/cgi.html):

    
    
    import cgi
    form = cgi.FieldStorage()
    print form["username"]
    

If using [Django](http://docs.djangoproject.com/),
[Pylons](http://pylonshq.com/), [Flask](http://flask.pocoo.org/) or
[Pyramid](http://www.pylonsproject.org/projects/pyramid/about):

    
    
    print request.GET['username'] # for GET form method
    print request.POST['username'] # for POST form method
    

Using [Turbogears](http://turbogears.org/),
[Cherrypy](http://www.cherrypy.org/):

    
    
    from cherrypy import request
    print request.params['username']
    

[Web.py](http://webpy.org):

    
    
    form = web.input()
    print form.username
    

[Werkzeug](http://werkzeug.pocoo.org/):

    
    
    print request.form['username']
    

If using Cherrypy or Turbogears, you can also define your handler function
taking a parameter directly:

    
    
    def index(self, username):
        print username
    

[Google App
Engine](https://developers.google.com/appengine/docs/python/gettingstartedpython27/introduction):

    
    
    class SomeHandler(webapp2.RequestHandler):
        def post(self):
            name = self.request.get('username') # this will get the value from the field named username
            self.response.write(name) # this will write on the document
    

So you really will have to choose one of those frameworks.

