请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

login页面加载不出来

from flask import Blueprint,send_from_directory
from application import app

route_static = Blueprint(‘static’,name)
@route_static.route("/path:filename")
def index(filename):
app.logger.info(filename)
return send_from_directory(app.root_path + “/web/static/”,filename)
这是static部分
class Application( Flask ):
def int(self,import_name,template_folder=None,root_path=None):
super( Application,self).int(import_name,template_folder=template_folder,root_path=root_path,static_folder=None)
self.config.from_pyfile(‘config/base_setting.py’) #加载配置文件
if “ops_config” in os.environ:
self.config.from_pyfile(‘config/%_setting.py’%os.environ[‘ops_config’])#加载ops_config所定义的文件

    db.init_app(self)

db=SQLAlchemy()
app=Application(name,template_folder=os.getcwd()+"/web/templates/",root_path=os.getcwd())
这是application部分
图片加载不出来

正在回答 回答被采纳积分+3

1回答

编程浪子 2020-03-16 23:51:30

你好

有个点我不太确认,因为你代码贴出来可能会由于种种原因和编辑器显示不一样

1:static.py

# -*- coding: utf-8 -*-
from flask import Blueprint,send_from_directory
from application import app
route_static = Blueprint('static', __name__)

@route_static.route("/<path:filename>")
def index( filename ):
    return send_from_directory(  app.root_path + "/web/static/" ,filename )

2:www.py

https://img1.sycdn.imooc.com//szimg/5e6fa05a099d68b619241272.jpg


如果你上面两步一样,请截图让我看看,不要贴代码,因为格式不够好,没办法看。


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信