Skip to content

Instantly share code, notes, and snippets.

@figengungor
Created August 8, 2013 23:16
Show Gist options
  • Select an option

  • Save figengungor/6189709 to your computer and use it in GitHub Desktop.

Select an option

Save figengungor/6189709 to your computer and use it in GitHub Desktop.
CS253 Udacity Problem Set 2
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