Skip to content

Instantly share code, notes, and snippets.

@gtracy
Created November 5, 2012 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtracy/4014715 to your computer and use it in GitHub Desktop.
Save gtracy/4014715 to your computer and use it in GitHub Desktop.
A tiny redirector app that runs on App Engine
import os
import logging
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
blog_slugs = {
'my-post' : '/12/09/',
'my-second-post' : '/12/12/'
}
class MainHandler(webapp.RequestHandler):
def get(self,slug=None):
if( slug is not None ):
if( slug in blog_slugs.keys() ):
self.redirect('http://blog.gregtracy.com/%s/%s.html' % (blog_slugs[slug],slug))
else:
logging.debug('missed lookup for %s' % slug)
self.redirect('http://blog.gregtracy.com')
else:
self.redirect('http://blog.gregtracy.com')
return
## end MainHandler
def main():
logging.getLogger().setLevel(logging.DEBUG)
application = webapp.WSGIApplication([('/(.*)', MainHandler),
],
debug=True)
util.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