-
-
Save kzinglzy/5b3143491771b3f63d84 to your computer and use it in GitHub Desktop.
chinese url with tornado
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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