python web framework knowledge

A complete web application: server receives a request from the browser, the web server will return the requested content to the browser so that the browser is displayed. [And before the browser and the server transport protocol is HTTP]

http: html is transmitted over the network protocol used to communicate the browser and server.

html: One definition is the text of the page.

 

Common status codes!

200 ok request was successful. GET and POST requests are generally used for

 

404 not found the server can not find the resources (web) at the request of the client. By this code, web designers can set "you can not find the requested resource" personalized page

 

500 Internal Server Error Internal server error and can not fulfill the request

 

 

Content-Type (content type), generally refers to the Content-Type web pages exist for defining network file encoding type page, the browser will decide what form, what code reading this document, which is often seen Some of the results to the PHP page is clicked to download a file or a picture reasons.

Content-Type header tells the client to return the actual content type of the content.

Syntax:

Content-Type: text/html; charset=utf-8 Content-Type: multipart/form-data; boundary=something
content-type:application/javascript

 

 HTTP requests:
Process:
1, the browser sends a request to the server http: [1, method (GET --- only request resources POST ---- ship with user data) 2, 3 path, domain 4, other related header, if it is POST, request comprising a body including user data]
 
2, the server returns http response to the browser, including [1, status code. 2, Content-Type Response Type []. 3. Other relevant header. ]
 
http protocol includes a highly scalable, can be in html resource links to other servers, so that the pressure is dispersed to each request server, and a site may be linked to other sites, numerous sites linked world wide web is www [ ]
 
 
 
 
 

 

 

 

WSGI: web Server Gateway interface [web server gateway interface]

Principle: Request web developers to implement a function, it can respond to http requests.

example:

def application(environ , start_response):

     start_response('200 ok',[('Content-Type','text/html')])

     return '<h1>hello ,web</h1>'

 

environ: a http request containing all the information dict objects

start_response: sending a http response function

 

 

In the application () function: Call:

     start_response('200 ok',[('Content-Type','text/html')])

 

 

 

 

Guess you like

Origin www.cnblogs.com/1314520xh/p/11621096.html