在所有的烧瓶路由中添加一个前缀我有一个前缀,我想添加到每条路线。现在,我在每个定义的路径中添加一个常量。有办法自动做到这一点吗?PREFIX = "/abc/123"@app.route(PREFIX + "/")def index_page():
return "This is a website about burritos"@app.route(PREFIX + "/about")def about_page():
return "This is a website about burritos"
3 回答
白衣非少年
TA贡献1155条经验 获得超0个赞
bp = Blueprint('burritos', __name__, template_folder='templates')@bp.route("/")def index_page(): return "This is a website about burritos"@bp.route("/about")def about_page(): return "This is a website about burritos"
app = Flask(__name__)app.register_blueprint(bp, url_prefix='/abc/123')
添加回答
举报
0/150
提交
取消