-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
65 lines (53 loc) · 1.89 KB
/
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
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
#!/usr/bin/python2.7
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler, Application, url
from tornado.websocket import WebSocketHandler
import os
import sqlite3
import hashlib, uuid
import tidal_auth as ta
import tidal_settings as ts
import tidal_amt as t_amt
import sys
sys.path.append("./TaskMgr")
import TaskMgr as tm
import ReqBackEnd as rbe
import WorkMgr as wm
# Start Server
print('\n\n'+'-'*80)
print 'Server Started'
print('-'*80+'\n')
# Initialize the WrkDatabase
wm.W.WMinit()
app_settings = {
"login_url": ts.URL_PREFIX+"/login",
"template_path" : os.path.join(os.path.dirname(__file__), "templates"),
"static_path" : os.path.join(os.path.dirname(__file__), "static"),
"debug" : True,
"cookie_secret" : "Blorp",
"xsrf_cookies" : False,
}
def init_app():
ta.init_password_db()
if(not ts.LOCAL_TESTING):
t_amt.init_amt_hit_db()
t_amt.cancel_hits()
t_amt.post_hit(3)
return Application([url(ts.URL_PREFIX+ r"/rlogin", ta.reqLoginHandler),
url(ts.URL_PREFIX+ r"/dlogin", ta.devLoginHandler),
url(ts.URL_PREFIX+ r"/wlogin", ta.wrkLoginHandler),
url(ts.URL_PREFIX+ r"/login", ta.loginHandler),
url(ts.URL_PREFIX+ r"/logout", ta.logoutHandler),
url(ts.URL_PREFIX+ r"/RequesterTaskMgr", rbe.RequesterHandlerTask),
url(ts.URL_PREFIX+ r"/RequesterWorkMgr", rbe.RequesterHandlerWork),
url(ts.URL_PREFIX+ r"/hit", tm.hitHandler),
url(ts.URL_PREFIX+ r"/websocket", tm.WebSocketHandler),
url(r"/.*", ta.missingHandler)]
,
**app_settings
)
if __name__ == "__main__":
app = init_app()
print ts.PORT
app.listen(ts.PORT)
IOLoop.instance().start()