0
0
Flaskframework~20 mins

Route naming conventions in Flask - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flask Route Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Flask route naming conventions
Which of the following route names follows the best Flask naming convention for a URL that shows a user's profile page?
A/user-profile
B/UserProfile
C/user_profile
D/userProfile
Attempts:
2 left
💡 Hint
Think about readability and common URL patterns using hyphens or underscores.
component_behavior
intermediate
2:00remaining
Route behavior with trailing slashes
Given a Flask route defined as @app.route('/dashboard/'), what happens when a user visits /dashboard (without the trailing slash)?
AFlask raises a runtime error
BFlask returns a 404 Not Found error
CFlask serves the '/dashboard/' route without redirect
DFlask redirects to '/dashboard/' automatically
Attempts:
2 left
💡 Hint
Think about how Flask handles routes with trailing slashes and user requests without them.
📝 Syntax
advanced
2:00remaining
Correct route parameter syntax in Flask
Which of the following route definitions correctly captures an integer user ID in Flask?
Flask
@app.route(...)
A/user/<id:int>
B/user/<int:user_id>
C/user/<user_id:int>
D/user/<integer:user_id>
Attempts:
2 left
💡 Hint
Flask uses a specific syntax for typed route parameters.
🔧 Debug
advanced
2:00remaining
Debugging route conflicts in Flask
Consider these two Flask routes:
@app.route('/item/')
@app.route('/item/new')
What problem will occur when a user visits /item/new?
AThe '/item/new' route will never be reached because '/item/<id>' captures 'new' as id
BFlask will raise a runtime error due to duplicate routes
CBoth routes will work correctly without conflict
DFlask will redirect '/item/new' to '/item/<id>'
Attempts:
2 left
💡 Hint
Think about how Flask matches routes in order and how variable routes capture strings.
lifecycle
expert
3:00remaining
Order of route matching in Flask
Given these Flask routes:
1. @app.route('/post/')
2. @app.route('/post/archive')
3. @app.route('/post/')
In what order does Flask check these routes when a user visits /post/archive?
A2, 1, 3
B1, 3, 2
C1, 2, 3
D3, 1, 2
Attempts:
2 left
💡 Hint
Flask matches routes in the order they are defined in the code.