How to use GET and POST methods
This article mainly explains "how to use GET and POST methods". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use GET and POST methods".
GET and POST methods
The browser client passes information to the server in two ways: the GET method and the POST method.
Using the GET method to transfer data
The GET method sends the encoded user information to the server, and the data information is contained on the URL of the request page to "?" Number division, as follows:
Http://www.test.com/cgi-bin/hello.py?key1=value1&key2=value2
Some other comments about the GET request:
GET requests can be cached
GET requests are kept in the browser history
GET requests can be collected as bookmarks
GET requests should not be used when processing sensitive data
GET request has a length limit
GET requests should only be used to retrieve data
Simple url example: GET method
Here is a simple URL that uses the GET method to send two parameters to the hello_get.py program:
/ cgi-bin/test.py?name=&url= http://www.yisu.com
The following is the code for the hello_get.py file:
#! / usr/bin/python3
# CGI processing module
Import cgi, cgitb
# create instantiation of FieldStorage
Form = cgi.FieldStorage ()
# get data
Site_name = form.getvalue ('name')
Site_url = form.getvalue ('url')
Print ("Content-type:text/html")
Print ()
Print ("")
Print ("")
Print ("")
Print ("CGI Test instance")
Print ("")
Print ("")
Print ("% s official website:% s"% (site_name, site_url))
Print ("")
Print ("")
Modify the hello_get.py after the file is saved, and modify the file permission to 755:
Chmod 755 hello_get.py thank you for reading, the above is the content of "how to use GET and POST methods". After the study of this article, I believe you have a deeper understanding of how to use GET and POST methods, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!