Python's web App

Source: Internet
Author: User

Web Apps

A Web application is an application that can be accessed through the Web, and the greatest benefit is that the user has easy access to the application, and the user needs only a browser and no additional software to install. There are two modes of application: C/S,/b. c/S is a client/server-side program, which means that such programs generally run independently. and b/S is browser-side/server-side applications, such applications generally with the help of Google, Firefox and other browsers to run. Web applications are generally b/s mode. Web applications are first "applications", and programs written in standard programming languages, such as Java,python, are not inherently different. In the sense of network programming, the browser is a socket client, and the server is a socket service side.

1 ImportSocket2 3 defhandle_request (client):4 5Request_data = CLIENT.RECV (1024)6     Print("Request_data:", Request_data)7 8Client.send ("http/1.1 ok\r\nstatus:200\r\ncontent-type:text/html\r\n\r\n". Encode ("UTF8"))9Client.send ("". Encode ("UTF8"))Ten  One defMain (): A  -Sock =Socket.socket (socket.af_inet, socket. SOCK_STREAM) -Sock.bind (('localhost', 8812)) theSock.listen (5) -  -      whileTrue: -         Print("The server is waiting for client-connection ....") +Connection, address =sock.accept () - handle_request (Connection) + connection.close () A  at if __name__=='__main__': -  -Main ()

Python's web App

Related Article

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.