Robyn
Robyn copied to clipboard
Update doc for Dynamic Routes
Hello, I am currently testing the framework on version 0.37, and I have noticed an issue with accessing the path parameter.
The documentation mentions the following code:
from robyn import jsonify
@app.post("/jsonify/:id")
async def json(request):
print(request["path_params"]["id"])
return jsonify({"hello": "world"})
However, when executing this example, the following error occurs:
TypeError: 'builtins.Request' object is subscriptable
To make it work, you should correct the example as follows:
@app.post("/jsonify/:id")
async def json(request):
# First example
id = request.path_params["id"]
# Or
id = request.path_params.get('id')
return jsonify({"hello": "world"})
Thanks