Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use GET and POST methods

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report