33 lines
700 B
Python
33 lines
700 B
Python
import socket
|
|
|
|
def html_response():
|
|
html_content = """
|
|
<html>
|
|
<head>
|
|
<title>Hello</title>
|
|
</head>
|
|
<body>
|
|
<h1>Здравствуйте</h1>
|
|
<p1>Текст</p1>
|
|
</body>
|
|
</html>
|
|
"""
|
|
return html_content
|
|
|
|
serv_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
serv_sock.bind(('0.0.0.0', 12346))
|
|
|
|
serv_sock.listen(5)
|
|
|
|
while True:
|
|
client_sock, client_addr = serv_sock.accept()
|
|
data = client_sock.recv(1024)
|
|
print(data.decode())
|
|
html_resp = html_response()
|
|
http_resp = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\n" + html_resp
|
|
client_sock.sendall(http_resp.encode())
|
|
client_sock.close()
|
|
|
|
#test
|