Static_url Challenge in Tornado

I am starting to work with a Python and Tornado web map. When I studied part of the template in the book " Introduction to Tornadoes" , one line confused me:

<link rel="stylesheet" href="{{ static_url("style.css") }}"> 

How can an application know where to call the static_url function if there is no library imported into the namespace? I found static_url() in the Tornado web module, but I cannot figure out how this function can be successfully called in this template file?

+4
source share
1 answer

The RequestHandler class has a get_template_namespace () method, documented here . If you click on the source link, you will see how it creates the dictionary , where 'static_url' is set to self.static_url .

+5
source

Source: https://habr.com/ru/post/1469003/


All Articles