Measuring open the road to one hundred twenty-six: flask of request data acquisition request

 

 

You can get all the information according to the request of the request object flask

path = request.path # address acquisition request
method = request.method # acquisition request method
ip = request.remote_addr # request source IP
form # = Request.Form form form data acquired
value = request.values # Get the query string / form data
headers = # Request.Headers region after the header information
User_Agent = request.headers [ 'User-Agent '] acquired information # browser initiating a request
host = request.headers [ 'host'] # host
name = request. args.get ( 'name', "not acquired name") # Get the designated parameter
environ = request.environ # environment
full_path = request.full_path # full path
URL = request.url
the base_url = request.base_url
url_root = request.url_root
si_xhr = request.is_xhr # XMLHTTPRequest request whether the
blueprint = request.blueprint # blueprint current name
endpoint = request.endpoint # root node, the currently executing function
view_args = request.view_args # View Parameter
name = request.args.get ( 'name', " not acquired name") # Get the designated parameter

 

 

 

Request / rq /

 

 

Coding #: UTF-. 8 
from the Flask Flask Import, Request

App = the Flask (name__ __)


@ app.route ( "/ RQ /")
DEF Get_Request ():
"" "Data Request" ""
path acquisition request # = request.path address
method = request.method # acquisition request method
ip = request.remote_addr # request source IP
form # = Request.Form form form data acquired
value = request.values # Get query string / data form
headers = request.headers # after the header information region
User_Agent = request.headers [ 'User-Agent '] # obtain information about the browser that initiated the request
host = request.headers [ 'host'] # host
name = request.args.get ( 'name', "There is no get to name") # Gets the specified parameters
environ = request.environ # environment
full_path = request.full_path # full path
url = request.url
= request.base_url the base_url
url_root = request.url_root
si_xhr = request.is_xhr # whether to request XMLHTTPRequest
blueprint = request.blueprint # blueprint current name
endpoint = request.endpoint # root node, the currently executed function
view_args = request.view_args # view parameter
name = request.args.get ( 'name', " not acquired name") # Get the designated parameter
return User_Agent # decoded


IF the __name__ == '__main__':
app.run (Debug = True)

Guess you like

Origin www.cnblogs.com/zhongyehai/p/11442874.html