-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathweb_server.py
More file actions
executable file
·78 lines (63 loc) · 1.47 KB
/
Copy pathweb_server.py
File metadata and controls
executable file
·78 lines (63 loc) · 1.47 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python
import os, sys, time, signal
#
sys.path.append( './lib/' )
#
import module_web as server
import core as core
import threading
import socket
#
# #####################################
# # FUNCTIONS
# #####################################
# # Print basic usage
# def print_usage():
# print "Intended Use:"
# print "%s <BROADCAST ADDRESS>" % (sys.argv[0])
# print "Eg: %s 0.0.0.0:8815" % (sys.argv[0])
#
# #####################################
# # MAIN
# #####################################
# if len(sys.argv) != 2:
# print_usage()
# sys.exit(1)
#
# # Run web interface
# pB_web.init()
#
# sys.exit(0)
class WebServer(threading.Thread):
abort = False
running = False
app = None
def __init__(self):
threading.Thread.__init__(self)
self.app = server.init()
def shutDown(self):
self.quit()
self.join()
def run(self):
while True and not self.abort:
try:
self.app.run()
except socket.error, e:
print e
pass
#self.app.start()
#try:
#self.app.start()
#except:
#self.app.stop()
#self.app = server.init()
#except Exception e
time.sleep(1)
def isRunning(self):
return self.running
def quit(self):
self.abort = True
self.app.stop()
def canShutdown(self):
return (self.abort and not self.running)
webServer = WebServer()