Created
July 1, 2014 00:27
-
-
Save jonatasemidio/51a4d1a49a0b339d73aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from google.appengine.api import users | |
| from google.appengine.ext import webapp | |
| from google.appengine.ext.webapp.util import run_wsgi_app | |
| from google.appengine.ext import db | |
| from google.appengine.ext.webapp import template | |
| from google.appengine.api import memcache | |
| # Set the debug level | |
| _DEBUG = True | |
| class BaseRequestHandler(webapp.RequestHandler): | |
| """Base request handler extends webapp.Request handler | |
| It defines the generate method, which renders a Django template | |
| in response to a web request | |
| """ | |
| def generate(self, template_name, template_values={}): | |
| """Generate takes renders and HTML template along with values | |
| passed to that template | |
| Args: | |
| template_name: A string that represents the name of the HTML template | |
| template_values: A dictionary that associates objects with a string | |
| assigned to that object to call in the HTML template. The defualt | |
| is an empty dictionary. | |
| """ | |
| # Respond to the request by rendering the template | |
| return template.render('', {}, debug=_DEBUG) | |
| class MainRequestHandler(BaseRequestHandler): | |
| def get(self): | |
| self.response.out.write(self.generate('index.html')); | |
| class SendEmail(BaseRequestHandler): | |
| def post(self): | |
| mail.send_mail(sender="jonatasemidio@gmail.com", to="jonatasemidio@gmail.com", subject="JESAPP", body="JESAPP") | |
| self.redirect('/') | |
| application = webapp.WSGIApplication([('/', MainRequestHandler), | |
| ('/email', SendEmail)], | |
| debug=True) | |
| def main(): | |
| run_wsgi_app(application) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment