Home > other >  Why does not display the python send HTML string to the browser
Why does not display the python send HTML string to the browser

Time:05-25

The import socket
The import threading

Server=socket. The socket ()
# binding to 0.0.0.0: on port 8000, because 0.0.0.0 makes external IP address to access the server. Note that the binding is the address of the server host
Server. The bind ((8000) '0.0.0.0')
Server. Listen ()

Def handle_sock (sock, addr) :
While True:
# the sock. Send (" welcome to server!" Encode (" utf8 "))
Tmp_data=https://bbs.csdn.net/topics/sock.recv (1024)
Print (tmp_data. Decode (" utf8 "))
# input_data=(https://bbs.csdn.net/topics/input)
Response_template=HTTP/1.1 200 OK "'


Build A Web Server

<body>
Hello World, this is a very simple HTML document.

"'

# print (response_template)

The sock. Send (response_template. Encode (" utf8 "))
  • Related