-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlers.py
51 lines (34 loc) · 1.26 KB
/
handlers.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
import tornado.web
import pandas as pd
class BaseHandler(tornado.web.RequestHandler):
def get(self):
self.render('index.html')
class OpinionHandler(tornado.web.RequestHandler):
def get(self):
self.render('opinion-poll.html')
class OpinionDataHandler(tornado.web.RequestHandler):
def get(self):
state = self.get_argument('state', 'goa')
data = pd.read_json('data/opinion-data.json')
self.write(data[state].to_json())
class ExitHandler(tornado.web.RequestHandler):
def get(self):
self.render('exit-poll.html')
class ExitDataHandler(tornado.web.RequestHandler):
def get(self):
state = self.get_argument('state', 'goa')
data = pd.read_json('data/exit-data.json')
self.write(data[state].to_json())
class VoterTOHandler(tornado.web.RequestHandler):
def get(self):
self.render('voter-turnout.html')
class TurnoutHandler(tornado.web.RequestHandler):
def get(self):
self.render('turnout-change.html')
class TableHandler(tornado.web.RequestHandler):
def get(self):
self.render('table.html')
class FetchResults(tornado.web.RequestHandler):
def get(self):
data = pd.read_csv('data/results-all.csv')
self.write(data.to_json(orient='records'))