Get get parameters under web.py

Source: Internet
Author: User

Relatively simple, directly on the code:

Import Weburls = (    '/', ' hello ') app = Web.application (URLs, Globals ()) class Hello:            def GET (self):        print Web.input ()        return ' GET Hello World '    def post:        print web.input ()        return "POST Hello World" if __ name__ = = ' __main__ ':    app.run ()

Save this piece of code and run it. Then enter in the browser:

http://127.0.0.1:8080/?name=instant7&passward=ins&date=2014.11.4

You can see the following records in the Python console:

<storage {' Date ': U ' 2014.11.4 ', ' name ': U ' instant7 ', ' Passward ': U ' ins '}>
127.0.0.1:16193--[04/nov/2014 14:34:20] "http/1.1 GET/"-OK

At this point, the get parameters are successfully obtained

If you want to get a parameter value in your code, refer to the following example:

i = web.input () name = I.namepassword = I.passworddate = i.dateprint name, password, date

  

Get get parameters under web.py

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.