Tornado static files serving url configuration

百般思念 提交于 2019-12-11 10:13:21

问题


I configured torando for serving static files for development purposes.

            settings = {
                    'template_path': 'templates',
                    'static_path': 'static'
            }

Inside my template files I am using static_url() to give proper path to my static files.

Because my html files have structure of static files already defined tornado static_url isn't showing correct path.

For example, on my server file is having url like

<link href="/myflz/resources/css/bootstrap.css" rel="stylesheet"/>

and after using static_url it is

<link href="/static/myflz/resources/css/bootstrap.css" rel="stylesheet"/>

How can I get rid of static before myflz because changing 'static_path': 'static' to 'static_path': 'myflz' doesn't work, it still uses static in front.


回答1:


You want static_url_prefix (which replaces /static/ at the front of the url) instead of static_path (which is the location on disk where the static files are stored).



来源:https://stackoverflow.com/questions/20787499/tornado-static-files-serving-url-configuration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!