Permalink
Browse files

Added support for .txt format

git-svn-id: https://urly.googlecode.com/svn/trunk@5 4bb6f403-2351-0410-a0e4-d75a30d34d26
  • Loading branch information...
1 parent 8cf6668 commit 798725a69f364fec7fc8e87b392a5e1814028b88 adam@stilesoft.com committed Oct 14, 2009
Showing with 6 additions and 1 deletion.
  1. +1 −1 main.py
  2. +3 −0 urly.py
  3. +2 −0 view.py
View
2 main.py
@@ -63,7 +63,7 @@ def get(self, code, format):
def main():
application = webapp.WSGIApplication([
- ('/([a-zA-Z0-9]{1,6})?(.xml|.json|.html)?', MainHandler)
+ ('/([a-zA-Z0-9]{1,6})?(.xml|.json|.html|.txt)?', MainHandler)
], debug=True)
wsgiref.handlers.CGIHandler().run(application)
View
3 urly.py
@@ -41,6 +41,9 @@ def to_xml(self):
msg += "<urly code=\"%s\" href=\"%s\" />\n" % (self.code(), self.href)
return msg
+ def to_text(self):
+ return "http://ur.ly/%s" % self.code()
+
def save_in_cache(self):
"""We don't really care if this fails"""
memcache.set(self.code(), self)
View
2 view.py
@@ -31,6 +31,8 @@ def render_main(handler, values=None):
render_raw(handler, "application/json", urly.to_json())
elif (format == '.xml'):
render_raw(handler, "application/xml", urly.to_xml())
+ elif (format == '.txt'):
+ render_raw(handler, "text/plain", urly.to_text())
else:
render_main(handler, { 'urly': urly })
elif (status == 400):

0 comments on commit 798725a

Please sign in to comment.