如何为 flask_cors 设置 Access-Control-Max-Age?
How to set Access-Control-Max-Age for flask_cors?
在我的烧瓶应用程序中,我需要设置Access-Control-Max-Age
。它的正确语法是什么?
from flask import Flask, send_from_directory
from flask_cors import CORS, cross_origin
app = Flask(__name__,static_folder='./build')
CORS(app)
看看 flask_cors.CORS
部分,max_age
部分。
max_age (timedelta, integer, string or None) –
The maximum time for which this CORS request maybe cached. This value is set as the Access-Control-Max-Age header.
根据文档,您可能需要使用此参数初始化 CORS
。
CORS(app, max_age=3600)
在我的烧瓶应用程序中,我需要设置Access-Control-Max-Age
。它的正确语法是什么?
from flask import Flask, send_from_directory
from flask_cors import CORS, cross_origin
app = Flask(__name__,static_folder='./build')
CORS(app)
看看 flask_cors.CORS
部分,max_age
部分。
max_age (timedelta, integer, string or None) –
The maximum time for which this CORS request maybe cached. This value is set as the Access-Control-Max-Age header.
根据文档,您可能需要使用此参数初始化 CORS
。
CORS(app, max_age=3600)