Created
September 10, 2012 11:06
-
-
Save kgleeson/3690349 to your computer and use it in GitHub Desktop.
Rot13 for AppEngine
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
| import webapp2 | |
| import cgi | |
| html=""" | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Unit 2 Rot 13</title> | |
| </head> | |
| <body> | |
| <h2>Enter some text to ROT13:</h2> | |
| <form method="post"> | |
| <textarea name="text" | |
| style="height: 100px; width: 400px;">%s</textarea> | |
| <br> | |
| <input type="submit"> | |
| </form> | |
| </body> | |
| </html> | |
| """ | |
| class MainPage(webapp2.RequestHandler): | |
| def write_form(self, text=''): | |
| self.response.write(html % text) | |
| def rot13(self, text): | |
| return text.encode('rot13') | |
| def get(self): | |
| self.write_form() | |
| def post(self): | |
| text = cgi.escape(self.request.get('text')) | |
| self.write_form(self.rot13(text)) | |
| app = webapp2.WSGIApplication([('/', MainPage)], | |
| debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment