2

我试图在我的 css 中包含 PIE.htc (http://www.css3pie.com/) 文件以解决 IE 中的一些问题。我包括这条线

behavior: url(/static/pie/PIE.htc);

对于相关的类。这似乎没有加载。

从阅读中,似乎我需要添加 MIME 类型

text/x-component 

对于我使用 Flask 的 Heroku 应用程序上的 .htc 文件。

有人对如何做到这一点有任何想法吗?

谢谢。

更新:

我认为可能类似于以下内容的东西会起作用,但似乎不行。

@app.route('/PIE.htc')
def pie():
    handle = open('static/pie/PIE.htc','r+')
    return Response(handle, mimetype = 'text/x-component')
4

1 回答 1

0

你的代码对我有用。这是我完整的测试应用程序:

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)

Content-Type: test/x-component这在 HTTP 响应中为自己提供所需的标头。

运行我的测试应用程序:

(test)day@office:~/test$ python test.py
 * Running on http://127.0.0.1:5000/
 * Restarting with reloader

在另一个终端中,使用curl仅针对标头发出 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 不熟悉,但也许他们在反向代理后面运行您的应用程序,该代理使用未配置为处理的 Content-Types?

于 2012-11-30T00:32:04.463 回答