我正在尝试在我的 css 中包含 PIE.htc (http://www.css3pie.com/) 文件以修复 IE 中的一些问题。我包括这条线
behavior: url(/static/pie/PIE.htc);
相关类(class)。这似乎没有加载。
从周围阅读,似乎我需要添加 MIME 类型
text/x-component
我的 Heroku 应用程序中使用 Flask 的 .htc 文件。
有人对如何做到这一点有任何想法吗?
谢谢。
更新:
我认为也许类似于下面的东西会起作用,但似乎不起作用。
@app.route('/PIE.htc')
def pie():
handle = open('static/pie/PIE.htc','r+')
return Response(handle, mimetype = 'text/x-component')
请您参考如下方法:
您的代码对我有用。这是我完整的测试应用程序:
import flask
app = flask.Flask(__name__)
@app.route('/')
def index():
handle = open(__file__, 'r+')
return flask.Response(handle, mimetype='test/x-component')
if __name__ == "__main__":
app.run(debug=True)
这会在 HTTP 响应中使用所需的 Content-Type: test/x-component header 。
运行我的测试应用:
(test)day@office:~/test$ python test.py
* Running on http://127.0.0.1:5000/
* Restarting with reloader
在另一个终端中,使用 curl仅对 header 发出 HEAD 请求:
day@office:~$ curl -Is http://127.0.0.1:5000/
HTTP/1.0 200 OK
Content-Type: test/x-component
Connection: close
Server: Werkzeug/0.8.3 Python/2.7.3
Date: Fri, 30 Nov 2012 00:29:39 GMT
如果这在本地运行时也适用于您,那么它可能与 Heroku 运行时环境有关?我对 Heroku 不熟悉,但也许他们在反向代理后面运行您的应用程序,该代理会吃掉未配置为处理的内容类型?
