M
M
Max Payne2018-10-17 00:04:07
Python
Max Payne, 2018-10-17 00:04:07

Why is Tornado ignoring ALL POST requests?

The server is on Ubuntu Server 18.04, there are no specific ifconfig settings, etc. (default).

GENERAL_ROUTE = ((r"/(.*)", tornado.web.StaticFileHandler, {"path": settings.DIR_WWW_FILES,
                                                            "default_filename": "index.html"}),
                 (r"/vk/(.*?):(.*?)", handlers.VkCB),
                 (r"/tg/(.*?)", handlers.Tg),
                 (r"/donate/notification", handlers.Fk),)

HTTP_PORT = 20080
HTTP_ROUTE = ((r"/(.*?)", handlers.HttpMain),
              *GENERAL_ROUTE)

HTTPS_PORT = 20443
HTTPS_ROUTE = (*GENERAL_ROUTE,)

SSL = {"certfile": path.join(settings.DIR_SSL, "certificate.crt"),
       "keyfile": path.join(settings.DIR_SSL, "private.key"),
       "ca_certs": path.join(settings.DIR_SSL, "ca_bundle.crt")}


class Main(ModulesBase):
    def __init__(self):
        http = tornado.httpserver.HTTPServer(
            tornado.web.Application(HTTP_ROUTE)
        )
        https = tornado.httpserver.HTTPServer(
            tornado.web.Application(HTTPS_ROUTE),
            ssl_options=SSL
        )

        http.add_sockets(tornado.netutil.bind_sockets(HTTP_PORT))
        https.add_sockets(tornado.netutil.bind_sockets(HTTPS_PORT))

        tornado.process.fork_processes(0)

        tornado.ioloop.IOLoop.instance().start()

Error 405 for all POST. If you remove the first line from GENERAL_ROUTE - still 405 error for all POST. All handlers have a post method.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artyom, 2018-10-17
@tormich

hmmm. and if you remove the first url from GENERAL_ROUTE, then 405 comes to both http and https?
ps
I still think it's r"/(.*)"better to put the last one on the list.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question