路由参数

框架支持路由参数。

@app.route('/<tag>')
async def helloWorld(request, tag=None):
    return response.html('''
            <div>
                <h1>
                    hello, {}
                </h1>
            </div>'''.format(tag))

我们在路由中用<>尖括号包裹住一个名字,然后当请求的时候,框架就会自动解析url中的参数,并为你的函数添加一个参数。

results matching ""

    No results matching ""