does tornado accept unicode in the adress?
#coding: utf-8 (there is # dont know how to show it here...)
import tornado.ioloop
import tornado.web
class Abdou(tornado.web.RequestHandler):
def get(self):
self.write("hi")
miaw = tornado.web.Application([
(u'/ééé', Abdou),
])
if __name__ == "__main__":
miaw.listen(8000)
tornado.ioloop.IOLoop
in Flask it worked !!!
from flask import Flask
miaw = Flask(__name__)
@miaw.route(u'/ééé')
def abdou():
return "hi!"
if __name__ == '__main__':
miaw.run()
NB: the same problem when using escape like /hello world , but in Flask it works!
NB2: thank you "wisty" for the edit :) now it appears more professional as a code :p
Look at tornado.escape.url_escape(value)
and tornado.escape.url_unescape(value, encoding='utf-8')
.
Something like this:
#coding: utf-8 (there is # dont know how to show it here...)
import tornado.ioloop
import tornado.web
class Abdou(tornado.web.RequestHandler):
def get(self):
self.write("hi")
miaw = tornado.web.Application([
(tornado.escape.url_escape(u'/ééé'), Abdou),
])
if __name__ == "__main__":
miaw.listen(8000)
tornado.ioloop.IOLoop
You probably also want to be able to get urls that the user inputs. I think you do it like:
class Page(tornado.web.RequestHandler):
def get(self,title):
title = tornado.escape.url_unescape(title, encoding='utf-8')
self.write(title)
miaw = tornado.web.Application([
(tornado.escape.url_escape(u'/ééé/(*.)'), Page),
])
# you can get /ééé/page_name, where page_name can be unicode
if __name__ == "__main__":
miaw.listen(8000)
tornado.ioloop.IOLoop
it seems that it's a bug:
http://groups.google.com/group/python-tornado/browse_thread/thread/1f89cbeee05ba6fb/c028d3e4744eec8a?lnk=gst&q=unicode#c028d3e4744eec8a
and the link is dead :( the 404 is following me even here!