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 -