Permalink
Browse files

add main page and requirements.txt

  • Loading branch information...
cedricporter committed May 12, 2014
1 parent 436f960 commit 7df0366412eb49f210d1711c941f18632eb7e55e
Showing with 11 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −0 etc/config.py.sample
  3. +7 −1 main.py
  4. +2 −0 requirements.txt
View
@@ -1 +1,2 @@
etc/config.py
+.env/
View
@@ -2,6 +2,7 @@
PORT = 8865
+MAIN_PAGE_REDIRECT = "https://github.com/cedricporter/url-shorten"
SITE_URL = "http://163.gs/"
SHORT_ID_LENGTH = 5
View
@@ -43,6 +43,11 @@ def gen_cache_key(*args):
class MainHandler(tornado.web.RequestHandler):
+ def get(self):
+ self.redirect(config.MAIN_PAGE_REDIRECT)
+
+
+class ExpandUrlHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@tornado.gen.engine
def get(self, short_id):
@@ -87,8 +92,9 @@ def get(self):
application = tornado.web.Application([
+ (r"/", MainHandler),
(r"/short/?", ShortenUrlHandler),
- (r"/([a-zA-Z0-9]{%s})/?" % config.SHORT_ID_LENGTH, MainHandler),
+ (r"/([a-zA-Z0-9]{%s})/?" % config.SHORT_ID_LENGTH, ExpandUrlHandler),
])
if __name__ == "__main__":
View
@@ -0,0 +1,2 @@
+tornado==3.2.1
+tornado-redis==2.4.17

0 comments on commit 7df0366

Please sign in to comment.