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

Python web Foundation

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

# HTTP client-server

Client---- > Server

(

Get/http/1.1

Host:httpbln.org

User-Agent:Httple/0.9.9

Accept:*/*

)

Server---- > Client

(

Http/1.1 200 OK

Content-Length:580

Content-Type:applcation/json

Date:Tue,25...

Connection:keep-alive

)

1. Communicate through the exchange of requests and responses

two。 Do not save communication status

3. Use URL to locate resources on the Internet

4. Use the method to issue commands (GET, POST, HEAD, etc.) when requesting resources

5. Save traffic through persistent links

6. Using cookie for state management

Http request header

1. The first line defines the request type, document (selector), and protocol version

two。 Then comes the header line, including all kinds of information about the client

3. The header line is followed by a blank line, indicating the end of the header line

4. This is followed by information about the form or data that may appear in the event of uploading the file.

5. Each line of the header should be terminated with a carriage return or newline character ('\ r\ n')-under windows

Http response

1. The first line represents the HTTP protocol version, success code, and return message

two。 The response line is followed by a series of header fields that contain information about the type of document returned, document size, Web server software, cookie, and so on.

3. End the header with a blank line

4. Followed by the original data of the requested document

Common request methods for http

Method

Describe GET to get document POST

Publish data to a form

HEAD only returns header information PUT uploads data to the server

Common http status codes

Success Code (2xx): 200 (success) 201 (create) 202 (accept) 204 (No content)

Redirect (3xx): 300 (multiple options) 301 (permanent move) 302 (can be replaced by 303) 303 (temporary move) 304 (not modified)

Client error (4xx): 400 (request error) 401 (unauthorized) 403 (access prohibited) 404 (not found) 405 (method not allowed)

Server error (5xx): 500 (internal server error) 501 (not implemented) 502 (gateway error) 503 (service unavailable)

Python3 standard web library

Http: details of handling all client-server http requests

Client: dealing with the client part

Server: understands the various classes that implement the HTTP server

Cookies: support for processing HTTP cookie on the server side

Cookiejar: support for storing and managing HTTP cookie on the client side

Urllib: a http-based high-level library for writing clients that interact with HTTP servers, etc.

Request: handling client requests

Response: handling server-side responses

Parse: used to manipulate URL strings

Python Web framework

A web framework with at least the ability to handle client requests and server responses

Routing: parse the URL and find the corresponding server file or Python server code

Template: merge server data into HTML pages

Authentication and authorization: handle user names. Password and permissions

Session: handles the data that users need to store between multiple requests

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

Servers

Wechat

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

12
Report