A progressive learning repository for students to master Flask basics step-by-step.
Flask is a micro-framework for Python. Think of it as a toolbox that provides just the essentials to build a website. Unlike static HTML, Flask allows you to:
- Create dynamic web pages
- Use Python logic in your HTML (via Jinja2 templates)
- Handle user requests and send responses
By completing all parts, you will understand:
- ✅ Virtual Environments (
venv) - Creating isolated project environments - ✅ App Routing - Using
@app.route()to map URLs to functions - ✅ Jinja2 Templates - Passing Python variables to HTML
- ✅ The Request-Response Cycle - How browsers and servers communicate
- ✅ Dynamic Routing - Creating flexible URL patterns
Navigate to this project folder.
python -m venv venvWindows (Command Prompt):
venv\Scripts\activateWindows (PowerShell):
venv\Scripts\Activate.ps1Mac/Linux:
source venv/bin/activateYou should see (venv) at the beginning of your terminal line.
pip install flaskCreate a .gitignore file in the root folder with the following content:
venv/
__pycache__/
*.pyc
.env
study-flask/
├── README.md # You are here!
├── part-1/ # Hello Flask - The Basics
├── part-2/ # Templates - Rendering HTML
├── part-3/ # Jinja2 - Passing Variables
├── part-4/ # Dynamic Routes - Multiple Pages
└── part-5/ # Mini Project - Personal Website
| Part | Topic | What You'll Learn |
|---|---|---|
| Part 1 | Hello Flask | Minimal Flask app, @app.route, running the server |
| Part 2 | Templates | templates/ folder, render_template() function |
| Part 3 | Jinja2 Variables | Passing data from Python to HTML with {{ }} |
| Part 4 | Dynamic Routes | Multiple routes, URL parameters with <variable> |
| Part 5 | Mini Project | Build a complete personal website with Flask |
- Make sure your virtual environment is activated (you see
(venv)) - Navigate to the part folder:
cd part-1 - Run the Flask app:
python app.py
- Open your browser and go to:
http://localhost:5000 - Press
Ctrl+Cin terminal to stop the server
After completing all parts, submit:
- Screenshot 1: Terminal showing
(venv)activated and Flask server running - Screenshot 2: Browser at
localhost:5000showing your website - Screenshot 3: Your
app.pycode highlighting the@app.route
Caption: "Successfully launched my first Python server! My personal website is now being served by Flask."
- Always activate
venvbefore running any Flask app - If you see an error, read it carefully - Python errors are helpful!
- Use
debug=Trueduring development to see live changes - Press
Ctrl+Cto stop the server before running a different part
# Minimal Flask App Structure
from flask import Flask # Import Flask
app = Flask(__name__) # Create app instance
@app.route('/') # Define route (URL path)
def home(): # Function that handles the route
return "Hello Flask!" # Response sent to browser
if __name__ == '__main__':
app.run(debug=True) # Start the serverHappy Learning! 🎉