Implemented a ROT13 Encryption Web App

The Source Code for the Python Web App using Templates (jinja2):
[sourcecode language="python"]
import os # operating system fumctions
import re # regular expression module
from string import letters

import webapp2
import jinja2

from google.appengine.ext import db

template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir), autoescape = True)

def render_str(template, **params):
t = jinja_env.get_template(template)
return t.render(params)

class MainHandler(webapp2.RequestHandler):
def render(self, template, **kw):
self.response.out.write(render_str(template, **kw))

def write(self, *a, **kw):
self.response.out.write(*a, **kw)

class Rot13(MainHandler):
def get(self):

def post(self):
rot13 = ''
text = self.request.get('text')
if text:
rot13 = text.encode('rot13')

self.render('rot13-form.html', text=rot13)

app = webapp2.WSGIApplication([
('/', Rot13)],
Source code for the Template positioned in a folder 'templates':
[sourcecode language="html"]</pre>
<!DOCTYPE html>

<title>Unit 2 Rot 13</title>

<h2>Enter some text to ROT13:</h2>
<form method="post">
<textarea name="text"
style="height: 100px; width: 400px;">{{text}}</textarea>
<input type="submit">


4 thoughts on “Implemented a ROT13 Encryption Web App”

    1. Hey Farbian, the content of the app.yaml is pretty standard. You can find the content below. If you you run into problems I’m happy to help you further! Best Regards, Dennis

      application: yourapplicationname
      version: 1
      runtime: python27
      api_version: 1
      threadsafe: yes

      – url: /static
      static_dir: static

      – url: .*

      – name: jinja2
      version: latest

Leave a Reply