2024-04-17 21:54:13 -04:00
|
|
|
# server.py
|
|
|
|
# simple listener to an IP port to test the phomemo plugin
|
|
|
|
|
|
|
|
import socket
|
|
|
|
|
|
|
|
PORT = 9100 # Port to listen on
|
|
|
|
|
|
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
s.bind(('', PORT))
|
|
|
|
s.listen(1)
|
|
|
|
while True:
|
|
|
|
conn, addr = s.accept()
|
|
|
|
print(addr)
|
2024-04-18 00:44:12 -04:00
|
|
|
printer = open('test.json', 'wb')
|
2024-04-17 21:54:13 -04:00
|
|
|
while True:
|
2024-04-17 22:23:16 -04:00
|
|
|
data = conn.recv(91000)
|
2024-04-17 21:54:13 -04:00
|
|
|
print('data received')
|
|
|
|
print('Sending to printer...')
|
|
|
|
printer.write(data)
|
|
|
|
if not data:
|
2024-04-17 22:23:16 -04:00
|
|
|
break
|
|
|
|
printer.close()
|