Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (28 sloc) 1.53 KB
layout title


Other languages: français | ...



You want user data from a form, or a url encoded parameter.


The web.input() method returns a object (a dictionary-like object) that contains the variables from the url (in a GET) or in the http header (in a POST). For example, if you go to the page, on the Python backend you'll want to extract that the id=10. Using web.input(), this becomes trivial:

class SomePage:
    def GET(self):
        user_data = web.input()
        return "<h1>" + + "</h1>"

Sometimes you may want to specify a default variable, in case none is given. The same code with a default value for x:

class SomePage:
    def GET(self):
        user_data = web.input(id="no data")
        return "<h1>" + + "</h1>"

Note that the web.input() values will be strings even if there are numbers passed to it.

What if you pass several of the same variable names, like this:


You need to let web.input know to expect multiple inputs, or it will clobber all but one. Pass the default value of a list to web.input and it will work correctly. For example, going to

class SomePage:
    def GET(self):
        user_data = web.input(id=[])
        return "<h1>" + ",".join( + "</h1>"
Jump to Line
Something went wrong with that request. Please try again.