Created
August 8, 2013 23:16
-
-
Save figengungor/6189709 to your computer and use it in GitHub Desktop.
CS253 Udacity Problem Set 2
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,cgi | |
| form='''<form method="post"> | |
| <textarea name="text"> | |
| %(text)s | |
| </textarea> | |
| <input type="submit"> | |
| </form> | |
| ''' | |
| def escape_html(s): | |
| return cgi.escape(s, quote = True) | |
| def rot13(text): | |
| return text.encode('rot13') | |
| class MainPage(webapp2.RequestHandler): | |
| def write_form(self, text="" ): | |
| self.response.out.write(form %{"text":escape_html(text)}) | |
| def get(self): | |
| self.write_form() | |
| def post(self): | |
| t=rot13(self.request.get('text')) | |
| self.write_form(t) | |
| app = webapp2.WSGIApplication([('/', MainPage)],debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment