I saw Generating a URL in the document, but I didn’t quite understand (the transfer of processing power between response functions).
@app.route('/')
async def index(request):
# generate a URL for the endpoint `post_handler`
url = app.url_for('post_handler', post_id=5)
# Redirect to `/posts/5`
return redirect(url)
@app.route('/posts/<post_id>')
async def post_handler(request, post_id):
return text(f"{post_id}")
I think it should return 5 instead of redirecting the link