0
0
Flaskframework~5 mins

Route naming conventions in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of route naming conventions in Flask?
Route naming conventions help keep URLs clear, consistent, and easy to understand for both developers and users. They make the app easier to maintain and navigate.
Click to reveal answer
beginner
Why should route names be lowercase and use hyphens instead of underscores?
Lowercase and hyphens improve readability and are more user-friendly in URLs. Hyphens separate words clearly, while underscores can be harder to spot in links.
Click to reveal answer
intermediate
How should RESTful routes be named for resources in Flask?
Use plural nouns for resource names (e.g., '/users') and HTTP methods to define actions (GET for read, POST for create, PUT/PATCH for update, DELETE for delete).
Click to reveal answer
beginner
What is a good practice for naming dynamic route parameters in Flask?
Use clear and descriptive names inside angle brackets, like '/user/<user_id>', so it’s obvious what data the route expects.
Click to reveal answer
beginner
Why avoid using file extensions (like .html) in Flask route URLs?
Avoiding file extensions keeps URLs clean and flexible. It also separates the URL from the technology used to render the page, making future changes easier.
Click to reveal answer
Which of these is the best route name for a list of blog posts in Flask?
A/blog-posts
B/BlogPosts
C/blog_posts
D/blogPosts
How should you name a route that shows details for a single user?
A/user/<id>
B/users/<user_id>
C/user_id
D/users/id
Which HTTP method is typically used with the route '/users' to create a new user?
AGET
BDELETE
CPOST
DPUT
Why should URLs avoid including file extensions like '.html'?
ATo make URLs shorter
BTo improve server speed
CTo allow spaces in URLs
DTo keep URLs technology-independent and clean
What is the recommended way to separate words in Flask route URLs?
AHyphens (-)
BCamelCase
CUnderscores (_)
DNo separation
Explain the key principles of naming routes in Flask for a beginner.
Think about how URLs should look simple and clear for users and developers.
You got /5 concepts.
    Describe how RESTful route naming works in Flask and why it is helpful.
    Consider how different HTTP methods map to actions like create, read, update, and delete.
    You got /4 concepts.