2.2 路由注册方式

一、装饰器方式

直接在视图函数上添加@app.router('')即可

@app.route('/hello/')
def hello():
    return 'success'

二、基于类的视图

统一规划管理路由的方式,建议即插视图使用这种方式

def hello():
    return 'success'

app.add_url_rule('/hello/', view_func=hello)

Last updated

Was this helpful?