Skip to content

Instantly share code, notes, and snippets.

@kinow
Created June 12, 2019 03:04
Show Gist options
  • Save kinow/cda18f38d66fd8fe48316782e2cb0be3 to your computer and use it in GitHub Desktop.
Save kinow/cda18f38d66fd8fe48316782e2cb0be3 to your computer and use it in GitHub Desktop.
Sample addslash Tornado
import tornado.ioloop
import tornado.web
class AddSlashHandler(tornado.web.RequestHandler):
@tornado.web.addslash
def get(self):
pass
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
def make_app():
return tornado.web.Application([
(r"/user/hello/", MainHandler),
(r"/(user|service)/([^/]+)", AddSlashHandler)
])
if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment