-
Notifications
You must be signed in to change notification settings - Fork 6
/
handlers.py
64 lines (57 loc) · 2.23 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
from google.appengine.ext import webapp
from sms_message import IncomingSMSMessage
from google.appengine.ext.webapp import template
from models import *
class MainPage(webapp.RequestHandler):
"""
This is a debugging page that allows me to test how the code handles messages.
"""
def get(self):
template_values = {}
path = os.path.join(os.path.dirname(__file__), 'templates/registration.html')
self.response.out.write(template.render(path, template_values))
class Register(webapp.RequestHandler):
def post(self):
self.response.out.write('<html><body>You wrote:<pre>')
self.response.out.write(cgi.escape(self.request.get('content')))
self.response.out.write(cgi.escape(self.request.get('phone_no')))
self.response.out.write('</pre></body></html>')
application = webapp.WSGIApplication(
[('/', MainPage),
('/register', Register)],
debug=True)
"""class Register(webapp.RequestHandler):
# Handles the form submission
debug = False
def get(self):
'Pass on get requests to the post handler.'
self.post()
def post(self):
'Handle the post request.'
msg = IncomingSMSMessage(self.request.get('phone'),
self.request.get('body'))
msg.confirm()
event = msg.save()
if msg:
template_values = {'event': event}
path = os.path.join(os.path.dirname(__file__), 'templates/notification.html')
self.response.out.write(template.render(path, template_values))
"""
class Event(webapp.RequestHandler):
"""
This is a debugging page that allows me to test how the code creates events.
"""
def get(self):
template_values = {}
path = os.path.join(os.path.dirname(__file__), 'templates/event.html')
self.response.out.write(template.render(path, template_values))
class ListVisitors(webapp.RequestHandler):
"""
This is a debugging page that allows me to test how the code creates events.
"""
def get(self):
visitors = db.GqlQuery("SELECT * FROM RegisteredVisitor ORDER BY phone DESC LIMIT 10")
template_values = {'visitors': visitors}
path = os.path.join(os.path.dirname(__file__), 'templates/visitor_list.html')
self.response.out.write(template.render(path, template_values))