我尝试过:
app = Flask(__name__, static_url_path='/web')
@app.route('/web/<path:path>')
def send_js(path):
response = send_from_directory('static/web', path)
response.headers["X-Frame-Options"] = "ALLOWALL" # I have an iframe which points to another website but cannot make it work
return response
我尝试了response.headers["X-Frame-Options"] = "ALLOWALL"
,以尝试能够在iframe中为我在html上的另一个网站提供服务,但是我得到了:
Refused to display 'https://www.w3schools.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
此问题不同于:How to set 'X-Frame-Options' on iframe?
因为这个其他问题假设我已经知道我应该添加标题“ X-Frame-Options”,并且已经将其设置为在烧瓶中作为响应,就像一些答案所暗示的那样,所以我在提供静态目录的flask示例如何添加此标头?是因为我使用的是静态目录服务吗?还有另一个原因吗?