I keep getting this error when trying to start main.py from my terminal. I’ve upgrade quart to no avail.
Traceback (most recent call last):
File “main.py”, line 12, in
@app.post(“/todos/string:username”)
AttributeError: ‘Quart’ object has no attribute ‘post’
Try this:
@app.route(“/todos/<string:username>”, methods=[“POST”])
1 Like
Same issue and fixed by replacing your changes.
Do you know is this a version mismatch bug or something else?
Sorry just saw this, the reason this works is if you omit the angle brackets (<>
) in the route path, Quart would treat the path segment as a literal string rather than a dynamic parameter. Meaning that in the OP’s post string:username
would only work if your username was literally “username”. By using the angle brackets (<>
) syntax, Quart knows that string:username
in the URL is a dynamic parameter and can extract its value for use within the route function.
Hope that helps