Skip to content

Instantly share code, notes, and snippets.

@kzinglzy
Created November 3, 2014 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzinglzy/5b3143491771b3f63d84 to your computer and use it in GitHub Desktop.
Save kzinglzy/5b3143491771b3f63d84 to your computer and use it in GitHub Desktop.
chinese url with tornado
#!/usr/bin/env python
# coding:utf-8
from tornado.web import RequestHandler, Application
from tornado.ioloop import IOLoop
import urllib
class ChineseHandler(RequestHandler):
def get(self, chinese):
self.write('hello, {}'.format(chinese.encode("utf-8")))
if __name__ == '__main__':
chinese = urllib.quote("程序员")
app = Application(
[(u'/(?P<chinese>{})'.format(chinese), ChineseHandler), ])
app.listen(9000)
IOLoop.instance().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment