FlaskNot Started
Flask Routing
URL routing, dynamic segments, multiple methods, url_for
0%
Knowledge0%
Learn & DrillFluency0%
Drill & SpeedRetention0%
Mastery & ReviewConfidence0%
All modesKnowledge
Fluency
Retention
Knowledge Debt detected
You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.
Explanation
s map URLs to Python functions. Flask uses the @app.route() decorator.
python
@app.route("/users/<int:user_id>", methods=["GET", "DELETE"])
def user(user_id):
if request.method == "GET":
return jsonify({"id": user_id})
elif request.method == "DELETE":
return "", 204:dynamic-segment[A URL pattern like <int:id> that captures variable URL parts and passes them as arguments to the view function]s: <type:name> captures URL parts: - <string:name> (default) - <int:id> - <float:price> - <path:filename>
url_for generates URLs dynamically: ``python from flask import url_for url_for("user", user_id=42) # "/users/42"
How well did you understand this?
Next in Flask
Request & Response