通过金字塔中的https服务静态文件 [英] Serving static files via https in pyramid
问题描述
我想通过request.static_url('some_file')在金字塔中提供静态文件.由于提供了多种服务,我的模板显示了以下行:
i want to serve static files in pyramids via request.static_url('some_file'). Due to several services, my templates got lines like:
<script type="text/javascript" src="${request.static_url('dbas:static/first')}"></script>
<script type="text/javascript" src="${request.static_url('websocket:static/second')}"></script>
但不幸的是,方法static_url()仅提供 http 作为url_scheme的链接,但是我想要 https .我该如何实现?
But unfortunately the method static_url() only delivers links with http as url_scheme, but i want https. How can I achieve this?
谢谢!
推荐答案
简单,您只需指定所需的方案即可,例如:
Easy, you only need to specify the scheme you want, for example:
<script type="text/javascript" src="${request.static_url('dbas:static/first', _scheme='https')}"></script>
注意:您还可以指定_host或_port来定义URL.有关更多信息,请 http://docs.pylonsproject.org/projects/pyramid/zh-CN/latest/api/request.html#pyramid.request.Request.route_url
Note: You can also specify _host or _port to define the url. For more info http://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.route_url
这篇关于通过金字塔中的https服务静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!