-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
39 lines (29 loc) · 1.13 KB
/
server.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
import os
import tornado.web
from tornado.ioloop import IOLoop
from handlers import BaseHandler, OpinionHandler, OpinionDataHandler, ExitHandler, ExitDataHandler, VoterTOHandler, TurnoutHandler, TableHandler, FetchResults
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r'/', BaseHandler),
(r'/opinion-poll/?', OpinionHandler),
(r'/opinion-poll/data/?', OpinionDataHandler),
(r'/exit-poll/?', ExitHandler),
(r'/exit-poll/data/?', ExitDataHandler),
(r'/voter-turnout/?', VoterTOHandler),
(r'/turnout-change/?', TurnoutHandler),
(r'/table/?', TableHandler),
(r'/results/?', FetchResults),
]
settings = {
'template_path': os.path.join(os.path.dirname(__file__), 'templates'),
'static_path': os.path.join(os.path.dirname(__file__), 'static'),
'debug': True
}
super(Application, self).__init__(handlers, **settings)
def main():
app = Application()
app.listen(80)
IOLoop.instance().start()
if __name__ == '__main__':
main()