-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.py
48 lines (40 loc) · 1.52 KB
/
api.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from tornado import ioloop
from tornado import web
from tornado import options
from app.user import UserProcess, UserStatus, ShowtimeProcess
from app.rfid import UnlockShowtime, ListUnlockedUsers, AssociateRFID
from lib import config
from lib import processors
# Set basic options
options.define("port", default=6060, type=int, help="What port to run on")
options.define("debug", default=False, type=bool, help="Debug Mode")
options.define("config", default='dev',
type=str, help="Section of config file to read")
if __name__ == "__main__":
options.parse_command_line()
port = options.options.port
debug = options.options.debug
config.read_config(options.options.config)
CONFIG = config.CONFIG
processor_handlers = [
ph
for p in processors.processors
for ph in p.register_handlers()
]
print("Registering process handlers:")
print('\t' + "\n\t".join(ph[0] for ph in processor_handlers))
app = web.Application(
[
(r'/api/showtime/unlock', UnlockShowtime),
(r'/api/showtime/process', ShowtimeProcess),
(r'/api/users/unlocked', ListUnlockedUsers),
(r'/api/user/associate', AssociateRFID),
(r'/api/user/process', UserProcess),
(r'/api/user/status', UserStatus),
] + processor_handlers,
debug=debug,
cookie_secret=CONFIG.get("cookie_secret"),
)
print("Listening on port: " + str(port))
app.listen(port, protocol='https')
ioloop.IOLoop.current().start()