默认情况下,你具有静态文件的
static端点。还
Flask应用有以下参数:
static_url_path:可用于为网络上的静态文件指定其他路径。默认为
static_folder文件夹的名称。
static_folder:包含静态文件的文件夹,应在提供该文件
static_url_path。默认为应用程序根路径中的“静态”文件夹。
这意味着该
filename参数将采用文件的相对路径
static_folder,并将其转换为以下相对路径
static_url_default:
url_for('static', filename='path/to/file')会将文件路径从static_folder/path/to/file转换为url路径static_url_default/path/to/file。
因此,如果要从static/bootstrap文件夹中获取文件,请使用以下代码:
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap/bootstrap.min.css') }}">将转换为(使用默认设置):
<link rel="stylesheet" type="text/css" href="static/bootstrap/bootstrap.min.css">
另请参阅url_for文档。



