-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
48 lines (38 loc) · 1.47 KB
/
main.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
import webapp2
import jinja2
import os
from google.appengine.ext import db
from google.appengine.api import mail
#Main pages are home, about, events, resources
#Jinja templating setup
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape=True)
#HANDLERS
class GenericHandler(webapp2.RequestHandler):
def write(self, *a, **kw):
self.response.out.write(*a, **kw)
def render_str(self, template, **params):
t = jinja_env.get_template(template)
return t.render(params)
def render(self, template, **kw):
self.write(self.render_str(template, **kw))
class Home(GenericHandler):
def get(self):
self.render('home.html')
class Signup(GenericHandler):
def post(self):
user_address = self.request.get("email_address")
#if not mail.is_email_valid(user_address):
# prompt user to enter a valid address
# You entered an invalid email address.
#else:
sender_address = "[email protected]"
subject = "Canvas Response Requested %s" % user_address
body = """
This person wants your attention:
%s
""" % user_address
mail.send_mail(sender_address, "[email protected]", subject, body)
self.render("signup.html",email=user_address)
app = webapp2.WSGIApplication([('/', Home),('/signup',Signup)],
debug=True)