我有一个通过 Flask 部署的 Web 应用程序。我正在使用 OpenLayers map ,它请求文件夹 scriptdir/theme/default 中的样式表。我对我的解决方案不是很满意,所以我希望有人能给我提示,让我做得更好:
@app.route('/theme/default/style.css')
def get_openlayers_css():
return url_for('static', filename='jslib/theme/default/style.css')
javascript 控制台向我显示此警告:
Resource interpreted as Stylesheet but transferred with MIME type text/html: http://localhost:5000/theme/default/style.css
OpenLayers.Map.OpenLayers.Class.initialize OpenLayers.js:424
...
请求的样式表位于/static/jslib/theme/default/style.css 和/static/jslib 中的 OpenLayers.js 文件。我考虑过流式传输 css 文件,但我是 flask 的新手,因此我无法让它工作。
提前致谢!
问候
请您参考如下方法:
你最好用theme: null [1]选项配置你的 map ,这将禁用css的自动加载,并在页面中自行加载它。
1 - http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.theme
