📖 Scenario: You want to build a simple web app that shows a welcome message. You want to keep things easy and fast without extra features you don't need.
🎯 Goal: Build a minimal Flask app that shows a welcome message at the home page using Flask's simple micro-framework style.
📋 What You'll Learn
Create a Flask app instance named app
Define a route for the home page using @app.route('/')
Create a function home that returns the string 'Welcome to Flask!'
Run the app with app.run() at the end
💡 Why This Matters
🌍 Real World
Flask is great for small web apps or APIs where you want to keep things simple and fast without extra features.
💼 Career
Many jobs require building quick prototypes or small services, and Flask's micro-framework style helps you do that efficiently.
Progress0 / 4 steps
1
DATA SETUP: Import Flask and create app instance
Import Flask from the flask package and create a Flask app instance called app.
Flask
Hint
Use from flask import Flask and then app = Flask(__name__).
2
CONFIGURATION: Define the home page route
Use the @app.route('/') decorator to define the home page route.
Flask
Hint
Use @app.route('/') just before the function that handles the home page.
3
CORE LOGIC: Create the home page function
Define a function called home that returns the string 'Welcome to Flask!'.
Flask
Hint
Write def home(): and inside it return 'Welcome to Flask!'.
4
COMPLETION: Run the Flask app
Add app.run() at the end to start the Flask app.
Flask
Hint
Simply add app.run() at the end of your code to start the server.
Practice
(1/5)
1. Why is Flask called a micro-framework?
easy
A. Because it includes a built-in database and admin panel
B. Because it is designed only for small websites and cannot scale
C. Because it provides only the core features and lets you add extensions as needed
D. Because it requires a lot of setup and configuration before use
Solution
Step 1: Understand the meaning of micro-framework
A micro-framework provides only essential features, avoiding extra built-in tools to keep it simple and lightweight.
Step 2: Relate Flask's design to micro-framework traits
Flask offers core web handling and lets developers add only what they need via extensions, matching the micro-framework idea.
Final Answer:
Because it provides only the core features and lets you add extensions as needed -> Option C
Quick Check:
Micro-framework = core features only [OK]
Hint: Micro means minimal built-in features, add what you want [OK]
Common Mistakes:
Thinking Flask cannot scale for bigger projects
Assuming Flask has many built-in tools like admin panels
Believing Flask requires heavy setup before use
2. Which of the following is the correct way to create a basic Flask app?
easy
A. from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return 'Hello World!'