Вот код сервера:
Код: Выделить всё
import socket
html = open("build/web/index.txt", "r", errors = "ignore").read() # open html code saved as a text file in another directory, to store as a variable
HOST = "172.17.4.193"
PORT = 65432
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(5)
while True:
conn, addr = s.accept()
print(addr)
data = conn.recv(1024)
conn.send(bytes('HTTP/1.0 200 OK\n', encoding="utf-8"))
conn.send(bytes('Content-Type: text/html\n', encoding="utf-8"))
conn.send(bytes('\n', encoding="utf-8"))
conn.send(bytes(html, encoding="utf-8"))
conn.close()
Подробнее здесь: https://stackoverflow.com/questions/792 ... on-sockets
Мобильная версия