Commits

lenmore committed cc24360

增加Feed和重定向的Handler,为向下兼容。

Comments (0)

Files changed (2)

 ENABLE_DB_CACHE = False
 ENABLE_PAGE_CACHE = True
 
-DROPBOX = "http://dl.dropbox.com/u/1109390/website/omobox.com/_build"
+DROPBOX = "http://dl.dropbox.com/u/1109390/website/omobox.com/_build"
+
+remaps = {'/linux/spf-dkim-sendmail.html': '/2010/11/30/spf-dkim-sendmail'
+        }
+
     return path
 
 
+#class BaseWSGIApplication(webapp2.WSGIApplication):
+#    def __call__(self, environ, start_response):
+#            environ['PATH_INFO'] = url_rewrite(environ['PATH_INFO'])
+#            return super(BaseWSGIApplication, self).__call__(environ, start_response)
+
+
 class AnyHandler(webapp2.RequestHandler):
     @cache.set_page()
     def get(self):
             self.error(res.status_code)
 
 
+class FeedHandler(webapp2.RequestHandler):
+    @cache.set_page()
+    def get(self):
+        res = urlfetch.fetch(config.DROPBOX + '/feed')
+
+        if res.status_code == 200:
+            self.response.headers['Content-Type'] = 'text/xml'
+            self.response.write(res.content)
+        else:
+            self.error(res.status_code)
+
+
 class CachedPageListHandler(webapp2.RequestHandler):
     def get(self):
         self.response.write('<a href="/mcf">Flush Memcached</a> <br><br>')
         self.redirect("/mc")
 
 
+class RedirectHandler(webapp2.RequestHandler):
+    def get(self):
+        if self.request.path_qs in config.remaps:
+            self.redirect(config.remaps.get(self.request.path_qs, '/'), True)
+        else:
+            self.response.set_status(404)
+            self.response.write('Not Found <br>')
+            self.response.write('<a href="/">Home</a>')
+            
+
 app = webapp2.WSGIApplication([ ('/static/.*', StaticHandler)
+                                , ('/feed', FeedHandler)
+                                
+                                , ('/.*/.*\.html', RedirectHandler)
                                 , ('/mc', CachedPageListHandler)
                                 , ('/mcf', CacheFlushHandler)
                                 , ('/.*', AnyHandler) ]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.