ii-vision/server.py

28 lines
602 B
Python
Raw Normal View History

2019-01-05 23:31:56 +00:00
import socketserver
ADDR = "192.168.1.15"
PORT = 20000
2019-02-23 23:28:33 +00:00
FILE = "out.bin"
2019-01-05 23:31:56 +00:00
class ChunkHandler(socketserver.BaseRequestHandler):
def handle(self):
2019-02-23 23:28:33 +00:00
with open(FILE, "rb") as f:
data = f.read()
print("Sending %d bytes" % len(data))
self.request.sendall(data)
2019-01-05 23:31:56 +00:00
def main():
with socketserver.TCPServer(
(ADDR, PORT), ChunkHandler, bind_and_activate=False) as server:
server.allow_reuse_address = True
server.server_bind()
server.server_activate()
server.serve_forever()
if __name__ == "__main__":
main()