小编dem*_*rit的帖子

使用蓝图时找不到烧瓶URL

这确实很奇怪,但是正面临这个问题。一切正常,我几乎用完了该应用程序,但突然停了下来。我隔离了代码,我意识到当我注册一个蓝图并在路由上使用它时,它无法返回说没有找到URL。这是隔离的代码:

from flask import Flask, render_template, Blueprint

app = Flask(__name__)

home = Blueprint('home', __name__, static_folder='static', template_folder='template')
app.register_blueprint(home)


@home.route('/')  #<---This one does not work
# @app.route('/') <--- This one works
def index():
    return "This is the index route."
    # return render_template('layer.html')


if __name__ == '__main__':
    app.run()
Run Code Online (Sandbox Code Playgroud)

python blueprint flask

1
推荐指数
1
解决办法
1351
查看次数

标签 统计

blueprint ×1

flask ×1

python ×1