У меня есть код python для получения данных сокета rcv
от другого клиента. Можно ли отправить данные на веб-сайт? Нужно ли менять порт на 80?
#SERVER.py
import errno
import os
import socket
import time
import threading
import RPi.GPIO as GPIO
host = "192.168.10.95"
port = 12345
hostName = socket.gethostname()
ipAddress = socket.gethostbyname(hostName + ".local")
print(hostName)
print(ipAddress,':',port)
def accept_req(client,addr):
print ('Got connection from',addr)
while True:
try:
rcv = client.recv(1024).decode('utf-8')
if not rcv:
print("there is no rcv")
client.close()
print("closed")
break
print(rcv)
except socket.error as e:
print(os.strerror(e.errno))
client.close()
print("closed")
break
time.sleep(1)
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s.bind((host, port))
s.listen(0)
while True:
c, addr = s.accept()
task = threading.Thread(target = accept_req,args = (c,addr))
task.start()
<!--web app to recieve data-->
<html>
<head>
<title>server</title>
</head>
<body>
<font size=10><center>
<B>Server</B>
<p></p>
</center>
</font>
<script>
a = document.getElementsByTagName("p");
setInterval(function(){
a[0].innerHTML = "print socket data here";
},1000);
</script>
</body>
</html>
изображение модели проекта здесь введите описание изображения здесь