0
0
Flaskframework~30 mins

Flask extensions directory - Mini Project: Build & Apply

Choose your learning style9 modes available
Flask Extensions Directory
📖 Scenario: You are building a simple Flask web app that shows a list of popular Flask extensions and their descriptions. This helps developers quickly find useful tools to add to their projects.
🎯 Goal: Create a Flask app that stores Flask extensions data, configures a minimum popularity threshold, filters extensions based on that threshold, and finally displays the filtered list on a web page.
📋 What You'll Learn
Create a dictionary called extensions with exact keys and values for Flask extensions and their descriptions.
Add a variable called min_popularity to set the minimum popularity score for filtering.
Use a dictionary comprehension to create popular_extensions containing only extensions with popularity greater than or equal to min_popularity.
Create a Flask route / that renders an HTML template showing the filtered extensions.
💡 Why This Matters
🌍 Real World
Developers often need to list and filter tools or plugins in web apps. This project shows how to manage and display such data dynamically.
💼 Career
Knowing how to build Flask apps that handle data and render filtered views is a key skill for backend web development roles.
Progress0 / 4 steps
1
Data Setup: Create the Flask extensions dictionary
Create a dictionary called extensions with these exact entries: 'Flask-SQLAlchemy': {'description': 'Adds SQLAlchemy support', 'popularity': 95}, 'Flask-WTF': {'description': 'Forms with CSRF protection', 'popularity': 90}, 'Flask-Login': {'description': 'User session management', 'popularity': 85}, 'Flask-Migrate': {'description': 'Database migrations', 'popularity': 80}, and 'Flask-Mail': {'description': 'Email support', 'popularity': 70}.
Flask
Need a hint?

Use a dictionary with extension names as keys and another dictionary with description and popularity as values.

2
Configuration: Set the minimum popularity threshold
Add a variable called min_popularity and set it to 85 to filter extensions by popularity.
Flask
Need a hint?

Just create a variable min_popularity and assign the number 85.

3
Core Logic: Filter extensions by popularity
Use a dictionary comprehension to create a new dictionary called popular_extensions that includes only those extensions from extensions where the popularity is greater than or equal to min_popularity.
Flask
Need a hint?

Use a dictionary comprehension with for name, info in extensions.items() and an if condition on info['popularity'].

4
Completion: Create Flask route to display filtered extensions
Import Flask and render_template_string. Create a Flask app called app. Add a route / that returns an HTML page listing each extension name and description from popular_extensions using render_template_string. Use a simple unordered list in HTML.
Flask
Need a hint?

Use @app.route('/') to create the route and render_template_string with a simple HTML string that loops over popular_extensions.