2012-11-25 118 views
2

我正在尝试在我的css中包含PIE.htc(http://www.css3pie.com/)文件,以解决IE中的一些问题。我包括该行在Heroku中添加MIME类型的.htc文件加入Flask

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

为相关类。这似乎并未加载。

从阅读周围,看来我需要添加MIME类型

text/x-component 

为我的Heroku应用.HTC文件正在使用瓶。

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

谢谢。

UPDATE:

我想,也许类似于下面的东西的工作,但它似乎没有。

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

回答

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) 

这符合本身的HTTP响应所需的Content-Type: test/x-component头。

运行我的测试程序:

(test)[email protected]:~/test$ python test.py 
* Running on http://127.0.0.1:5000/ 
* Restarting with reloader 

在另一端,使用curl做的只是一个标题HEAD请求:

[email protected]:~$ 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并不熟悉,但也许他们在一个反向代理后面运行你的应用程序,该反向代理吃掉没有配置为处理的内容类型?