I just started learning Tornado and bumped into the first problem in my hello.py.
I followed the steps and codes given by “Introduction to Tornado”. Here is the code.
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)
class IndexHandler(tornado.web.RequestHandler):
def get(self):
greeting = self.get_argument('greeting','Hello')
self.write(greeting + ', friendly user!')
if __name__=="__main__":
tornado.options.parse_command_line()
app = tornado.web.Application(handers=[(r"/", IndexHandler)])
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
after I run it in other Terminal window by
curl http://localhost:8000/
I didn’t get the expected answer, which should be
Hello, friendly user!
Instead, the respond is something like
[I 121026 18:20:38 web:1359] 301 GET / (127.0.0.1) 1.12ms
I am so new to this that I have no idea how to solve it. The problem may sound really stupid buy please do me a favor and help me out! Thanks lot!!!!!
Not sure if it is the primary issue, but you misspelled
handlersin