0
0
Flaskframework~30 mins

Route naming conventions in Flask - Mini Project: Build & Apply

Choose your learning style9 modes available
Route Naming Conventions in Flask
📖 Scenario: You are building a simple web application using Flask. To keep your app organized and easy to understand, you need to follow good route naming conventions.Routes are the web addresses that users visit to see different pages or perform actions. Naming them clearly helps both developers and users know what each page does.
🎯 Goal: Create a Flask app with routes that follow clear and consistent naming conventions. You will define routes for a homepage, a user profile page, and a settings page.
📋 What You'll Learn
Create a Flask app instance named app
Define a route for the homepage at / with a function named home
Define a route for the user profile page at /user/profile with a function named user_profile
Define a route for the settings page at /settings with a function named settings
Each route function should return a simple string indicating the page name
💡 Why This Matters
🌍 Real World
Web developers use Flask route naming conventions to organize URLs clearly, making apps easier to maintain and navigate.
💼 Career
Understanding route naming is essential for backend web development roles using Flask or similar frameworks.
Progress0 / 4 steps
1
Create the Flask app instance
Import Flask from flask and create a Flask app instance called app.
Flask
Need a hint?

Use from flask import Flask and then app = Flask(__name__).

2
Define the homepage route
Use the @app.route decorator with the path / to define a function called home that returns the string 'Homepage'.
Flask
Need a hint?

Use @app.route('/') above a function named home that returns 'Homepage'.

3
Add the user profile route
Add a route with @app.route('/user/profile') and define a function called user_profile that returns the string 'User Profile Page'.
Flask
Need a hint?

Use @app.route('/user/profile') and a function named user_profile returning 'User Profile Page'.

4
Add the settings route
Add a route with @app.route('/settings') and define a function called settings that returns the string 'Settings Page'.
Flask
Need a hint?

Use @app.route('/settings') and a function named settings returning 'Settings Page'.