Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tornado POST 405: Method Not Allowed

For some reason, I am not able to use POST methods in tornado.

Even the hello_world example does not work when I change GET to POST.

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def post(self):
        self.write("Hello, world")

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

It throws "405 method not allowed". Any suggestions?

like image 761
Divyanshu Das Avatar asked Sep 25 '13 13:09

Divyanshu Das


1 Answers

Falsetru answer is a useful hint and yes, what you need is exactly a get method. But no, I don't think get and post method should behave the same. The semantics of the two methods is different. Please have a look at the HTTP specs http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html and consider Brabster answer to this question What is the difference between a HTTP-Get and HTTP-POST and why is HTTP-POST weaker in terms of security.

(sorry, my sentence should be better a comment to falsetru answer but my reputation don't allow)

like image 198
Marco De Paoli Avatar answered Oct 22 '22 21:10

Marco De Paoli