This repository has been archived by the owner on Feb 14, 2020. It is now read-only.
/
alertbirds.py
66 lines (57 loc) · 2.17 KB
/
alertbirds.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
66
#!/usr/bin/env python
import base64
import os
import sys
import uuid
# for tornado
sys.path.append(os.path.join(os.path.dirname(__file__), 'contrib'))
# for config
sys.path.append(os.path.join(os.path.dirname(__file__), 'etc'))
import tornado.web
import tornado.wsgi
import wsgiref.simple_server
from models.user import UserManager, User
from controllers.main import *
from controllers.alert import *
from controllers.savedsearch import *
from controllers.endpoint import *
from controllers.cron import *
from controllers.api.alert import *
from controllers.api.savedsearch import *
from controllers.api.endpoint import *
# cookie secret from http://groups.google.com/group/python-tornado/browse_thread/thread/9ea50651adee1150
settings = {
'title': u'Alert Birds',
'template_path': os.path.join(os.path.dirname(__file__), 'templates'),
'xsrf_cookies': True,
'cookie_secret': base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes),
'autoescape': None,
'debug': True
}
application = tornado.wsgi.WSGIApplication([
(r'/', MainHandler),
(r'/(.*)/api/alert/(.*)/(.*)/?', AlertAPIHandler),
(r'/(.*)/api/alert/(.*)/?', AlertAPIHandler),
(r'/(.*)/api/alert/?', AlertAPIHandler),
(r'/(.*)/api/savedsearch/(.*)/(.*)/?', SavedSearchAPIHandler),
(r'/(.*)/api/savedsearch/(.*)/?', SavedSearchAPIHandler),
(r'/(.*)/api/savedsearch/?', SavedSearchAPIHandler),
(r'/(.*)/api/endpoint/(.*)/(.*)/?', EndpointAPIHandler),
(r'/(.*)/api/endpoint/(.*)/?', EndpointAPIHandler),
(r'/(.*)/api/endpoint/?', EndpointAPIHandler),
(r'/(.*)/alert/(.*)/(.*)/?', AlertHandler),
(r'/(.*)/alert/(.*)/?', AlertHandler),
(r'/(.*)/alert/?', AlertHandler),
(r'/(.*)/savedsearch/(.*)/(.*)/?', SavedSearchHandler),
(r'/(.*)/savedsearch/(.*)/?', SavedSearchHandler),
(r'/(.*)/savedsearch/?', SavedSearchHandler),
(r'/(.*)/endpoint/(.*)/(.*)/?', EndpointHandler),
(r'/(.*)/endpoint/(.*)/?', EndpointHandler),
(r'/(.*)/endpoint/?', EndpointHandler),
(r'/cron/(.*)/(.*)/?', CronHandler),
(r'/(.*)/?', MainHandler) # must be last
], **settings)
def main():
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()