-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·29 lines (22 loc) · 1015 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
# encoding: utf-8
import argparse
import time
from http.server import HTTPServer
from handles import ServerHandler
from utils import get_local_ip
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='NETIO PUSH Data logger')
parser.add_argument('-n', '--host', help='Address to attach server to', required=False, default='0.0.0.0')
parser.add_argument('-p', '--port', help='Port to listen on', required=False, default=9000)
args = vars(parser.parse_args())
# {'host': 'localhost', 'port': 9000, 'name': 'log', 'output': 'log/'}
httpd = HTTPServer((args['host'], args['port']), ServerHandler)
print(time.asctime(), 'Server Starts - %s:%s' % (args['host'], args['port']))
print(f"Device - Target host HTTP server: {get_local_ip()}:9000/push/json")
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
httpd.server_close()
print(time.asctime(), 'Server Stops - %s:%s' % (args['host'], args['port']))