inventree-phomemo-plugin/inventree_phomemo/server.py

22 lines
No EOL
503 B
Python

# 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)
printer = open('test.json', 'w')
while True:
data = conn.recv(91000)
print('data received')
print('Sending to printer...')
printer.write(data)
if not data:
break
printer.close()