2
我有一个烧瓶web应用程序,它使用render_template如下。我需要添加一个内容安全策略作为额外的http响应标题在响应。我尝试以下方法,但都失败,并给我500添加响应标题烧瓶web应用
1.
from flask import \
Flask, \
render_template
app = Flask(__name__,template_folder='tmpl')
@app.route('/')
def index():
resp =make_response(render_template('index.html'))
resp.headers['Content-Security-Policy']='default-src \'self\''
return resp
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3001)
2.
@app.route('/')
def index():
resp =render_template('index.html')
resp.headers.add('Content-Security-Policy','default-src \'self\'')
return resp
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3001)
什么可以错在这里?
在我看到以下时我访问web应用程序为localhost终端:3001
127.0.0.1 - - [06 /月/ 2015年1点45分01秒] “GET/HTTP/1.1” 500 -