forked from codeforamerica/sheltraustin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InfoHandler.py
46 lines (35 loc) · 969 Bytes
/
InfoHandler.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
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import simplejson
from QueryHandler import QueryHandler
class InfoHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self):
if not self.request.arguments:
self.render('index.html')
return
email = ''
phone = ''
direction = ''
if 'email' in self.request.arguments:
email = self.request.arguments['email'][0]
if 'phone' in self.request.arguments:
phone = self.request.arguments['phone'][0]
if 'direction' in self.request.arguments:
direction = self.request.arguments['direction'][0]
print email
email_results = {}
phone_results = {}
if not phone=='':
phone_results = QueryHandler.get_sms(phone, direction)
if not email=='':
email_results = QueryHandler.get_email(email, direction)
output = {
'email': email_results,
'phone': phone_results
}
self.write(output)
self.flush()
self.finish()