Google app engine 使用蓝图动态生成烧瓶的路由

Google app engine 使用蓝图动态生成烧瓶的路由,google-app-engine,flask,Google App Engine,Flask,我喜欢为我的Flask应用程序生成路由,该应用程序托管在Google app Engine上。目前我正在使用蓝图生成路线。比如说 conference_routes = Blueprint('conference_routes', __name__) @conference_routes.route('/home/Conferences/QCCC-Mappleton-2015') def mappleton_conference(): return render_template('

我喜欢为我的Flask应用程序生成路由,该应用程序托管在Google app Engine上。目前我正在使用蓝图生成路线。比如说

conference_routes = Blueprint('conference_routes', __name__)


@conference_routes.route('/home/Conferences/QCCC-Mappleton-2015')
def mappleton_conference():
    return render_template('Mappleton-2015.html')
然后我从main.py注册了蓝图

app.register_blueprint(conference_routes)
这变得非常麻烦,尤其是当我们有超过100条路线时。我希望在数据库中定义路由,并在运行时动态构建它们

这可能吗?

答案显示了以下各项的使用:

answer提供了设置这些路线的有用信息,还提供了几个很好的示例

听起来,在设置应用程序变量后,您需要立即添加所有路由:

conference_routes = Flask(__name__)
# load info from database
# insert routes
如果您的文件都是1-1,就像您的示例一样,那么您甚至不需要该路由加载方法-只需从url中查找文件:

@conference_routes.route('/<path:path>')
def search_file(path):
    # (in)validate path
    # return html template or 404
@conference_routes.route(“/”)
def搜索_文件(路径):
#(in)验证路径
#返回html模板或404
@conference_routes.route('/<path:path>')
def search_file(path):
    # (in)validate path
    # return html template or 404