I'm wondering if it is possible in the Tornado framework to register multiple Application on the same IOLoop ?
Something like
application1 = web.Application([
(r"/", MainPageHandler),
])
http_server = httpserver.HTTPServer(application1)
http_server.listen(8080)
application2 = web.Application([
(r"/appli2", MainPageHandler2),
])
http_server2 = httpserver.HTTPServer(application2)
http_server2.listen(8080)
ioloop.IOLoop.instance().start()
Basically I'm trying to structure my webapp so that:
The simple thing is if you were to bind your applications to different ports:
...
http_server = httpserver.HTTPServer(application1)
http_server.listen(8080) # NOTE - port 8080
...
http_server2 = httpserver.HTTPServer(application2)
http_server2.listen(8081) # NOTE - port 8081
ioloop.IOLoop.instance().start()
This is the base case that Tornado makes easy. The challenge is that by routing to applications at the URI level you're crossing a design boundary which is that each application is responsible for all of the URIs that that are requested by it.
If they all really need to be serviced at the URI level not port, it would probably be best to host different applications on different ports and have Nginx/Apache do the URI routing - anything that involves messing with the Application/Request handling is going to be a world of hurt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With