Answer the question
In order to leave comments, you need to log in
How to redirect to TornadoWeb?
Hello. Please tell me how to make a Redirect (or set a parameter in Tornado itself, if there is such a possibility) so that:
When /static/template.css is requested , TornadoWeb takes static from another subdomain (nginx), and not locally from its server? As I understand it, there are several options:
1. Register a direct link to the subdomain everywhere ..
(not an option, because it is not universal, when you change the domain, you will have to replace links everywhere, etc.)
2. (Question) Register RedirectHandler to links like /static/FILE_NAME?
3. (Question) Register (somewhere?..) in Tornado so that it takes statics from another server
4. or maybe I missed some other option / method?
Answer the question
In order to leave comments, you need to log in
What does "taken" mean? The client takes and the server gives back. And it’s better that nginx, and not tornado, give statics on the combat server. I see two ways:
1. Specify location /static/ in the nginx configuration, define where and how the static is taken from (from the local server or a redirect to another server), and upstream all other requests to tornado.
2. In the base class for tornado handlers, override the get_template_namespace method so that the address of the static server is available in all templates
class BaseHandler(tornado.web.RequestHandler):
def get_template_namespace(self):
ns = super(BaseHandler, self).get_template_namespace()
ns.update({
'static_srv': 'static.domain.ru',
})
return ns
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question