Flask Blueprint找不到静态文件夹

 mobiledu2502878025 发布于 2022-12-21 17:50

我在Flask应用程序中设置了一个蓝图,但我似乎无法使我的静态文件夹工作.我试图联系到他时遇到404错误:

127.0.0.1 - - [11/Sep/2014 15:14:20] "GET /static/js/bootstrap.min.js HTTP/1.1" 404 -
127.0.0.1 - - [11/Sep/2014 15:14:20] "GET /static/static/css/bootstrap.min.css HTTP/1.1" 404 -

css one也附加静态两次.JS具有正确/静态但似乎不起作用.现在,我的静态文件夹位于蓝图根路径(app/dashboard)中.我试过把它插入app/static但我得到了同样的错误.

我有以下设置:

app/dashboard/__init__.py:

from flask import Blueprint
dashboard = Blueprint('dashboard', __name__, template_folder='templates', static_folder='static')
from application.dashboard import controllers

app/__init__.py:

# Blueprints      
from flask import Blueprint
from application.dashboard import dashboard
app.register_blueprint(dashboard)

app/templates/layout.html,我有一行引用两个静态文件,如下所示:



我的app/dashboard/static目录:

$ tree application/dashboard/static/
application/dashboard/static/
??? css
?   ??? bootstrap-theme.css
?   ??? bootstrap-theme.css.map
?   ??? bootstrap-theme.min.css
?   ??? bootstrap.css
?   ??? bootstrap.css.map
?   ??? bootstrap.min.css
??? fonts
?   ??? glyphicons-halflings-regular.eot
?   ??? glyphicons-halflings-regular.svg
?   ??? glyphicons-halflings-regular.ttf
?   ??? glyphicons-halflings-regular.woff
??? js
    ??? bootstrap.js
    ??? bootstrap.min.js

知道这里发生了什么吗?如何正确构建我的蓝图?我按照Flask文档中的说明操作,我收到此错误.

谢谢.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有