51.web applications

Source: Internet
Author: User

1.web Reference Program

The web, also known as the World Wide Web, is a global, dynamically interactive, cross-platform distributed graphical information system based on hypertext and HTTP (wide). is a Web service built on the Internet that provides a graphical, easy-to-access, and intuitive interface for browsing and browsing information on the Internet

An application that can be accessed through the Web, usually b/s mode

1.1http protocol

Hyper text Transfer Protocol, Hypertext Transfer Protocol for transfer of text between a World Wide Web server and a local browser

1.2http protocol Features

Application layer protocol based on TCP/IP protocol

Based on request-response mode (one-time handshake)

The HTTP protocol itself does not save the communication state between the request and the response

When the server finishes processing the customer's request and receives the customer's answer, the connection is disconnected. This way, the transmission time can be saved

1.3http request agreement and corresponding protocol

About the Request protocol format

Note: Get is different from POST request

Get submitted data is placed after the URL, in the? Splitting URLs and transferring data, connecting parameters with &

The data size of the Get commit is limited (because the browser has a limit on the URL length), and the post has

About the Request protocol format

Response Status Code

The result of the request returned when the client-side service sends a request. The status code can be used to know if the server is processing the request correctly, and the response is divided into the following five types

1.2 Browser emulation socket client interacts with Python server

The browser is actually the client that encapsulates the socket, and in Python it responds to the browser client by simulating the server.

ImportSocketser=socket.socket () port= ('', 8800) Ser.bind (port) ser.listen () whileTrue:Print('Server waitting') conn,addr=ser.accept () msg= CONN.RECV (1024)    Print("Data", msg)#reading HTML filesWith open ("day2.html","RB") as F:data=F.read ()#fixed syntax format, based on the 1.1 version of the HTTP protocolConn.send (b'http:\\1.1 ok\r\n\r\n%s'%data) Conn.close ()


<! DOCTYPE html>"ZH-CN">"UTF-8"> <title> Login Interface </title>p{Color:gray; Background-Color:yellow; }    </style> <form> <textarea name="Stay White"Rows="4"cols=" the"> </textarea> </form> <fieldset> <div align="Center"> "username"Placeholder="Email/Mobile account/Xiaomi ID"><br><br> <input type="Password"Placeholder="Password"><br><br> <a href=""> Sign in </a> </fieldset> </div></body>View Code

Run the server first, open the browser at this time, the above input can respond to the message from the server side, print the service side of the information

51.web applications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.