Created
February 16, 2012 00:56
-
-
Save pamelafox/1840412 to your computer and use it in GitHub Desktop.
App Engine Redirect Handler
This file contains 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
""" | |
Licensed under the Apache License, Version 2.0: | |
http://www.apache.org/licenses/LICENSE-2.0 | |
""" | |
from google.appengine.ext import webapp | |
from google.appengine.ext.webapp.util import run_wsgi_app | |
redirects = { | |
'/learning': 'http://blog.pamelafox.org', | |
'/learning/reusing-html-css-js.html': 'http://blog.pamelafox.org/2011/12/reusing-htmlcssjs-across-web-mobile.html', | |
'/learning/using-oauth-apis-appengine.html': 'http://blog.pamelafox.org/2011/12/using-3-legged-oauth-apis-with-flask.html', | |
'/learning/upgrading-jquery-templates-to-jsrender.html': 'http://blog.pamelafox.org/2011/12/upgrading-from-jquery-templates-to.html', | |
'/learning/porting-jquery-to-zepto.html': 'http://blog.pamelafox.org/2011/11/porting-from-jquery-to-zepto.html', | |
'/learning/logging-js-on-ios.html': 'http://blog.pamelafox.org/2011/10/logging-js-errors-on-ios-with-phonegap.html', | |
'/learning/code-quality-tools.html': 'http://blog.pamelafox.org/2011/10/code-quality-tools.html', | |
'/learning/phonegap-loading-performance.html': 'http://blog.pamelafox.org/2011/10/phonegap-loading-performance-in-ios.html', | |
'/learning/js-css-makefile.html': 'http://blog.pamelafox.org/2011/10/js-css-compiling-compression-cache.html', | |
'/learning/javascript-modularization.html': 'http://blog.pamelafox.org/2011/10/modularizing-my-javascript.html', | |
'/learning/grammatical-personalization-js.html': 'http://blog.pamelafox.org/2011/10/grammatical-personalization-in-js.html', | |
'/learning/user-stats-visualization.html': 'http://blog.pamelafox.org/2011/10/user-stats-visualization-with.html', | |
'/learning/client-side-error-logging.html': 'http://blog.pamelafox.org/2011/10/client-side-error-logging.html', | |
'/learning/git-commit-check.html': 'http://blog.pamelafox.org/2011/09/pre-deploy-git-check.html', | |
'/learning/emailing-error-logs.html': 'http://blog.pamelafox.org/2011/09/sending-errors-to-email-in-app-engine.html', | |
'/learning/switching-jquerymob-bootstrap.html': 'http://blog.pamelafox.org/2011/09/switching-from-jquery-mobile-to-twitter.html', | |
'/learning/spriting-with-compass.html': 'http://blog.pamelafox.org/2011/08/spriting-with-compass.html', | |
'/shuffling': 'http://www.youtube.com/watch?v=KQ6zr6kCPj8' | |
} | |
class RedirectHandler(webapp.RequestHandler): | |
def get(self): | |
path = self.request.path | |
if path in redirects: | |
self.redirect(redirects[path]) | |
else: | |
self.redirect('http://pamelafox.org') | |
application = webapp.WSGIApplication( | |
[(r'.*', RedirectHandler)], | |
debug=True) | |
def main(): | |
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