- Flask Introduction
- Row Factory in SQLite
- Flask Authentication
Flask is a micro web framework written in Python. It’s called “micro” not because it’s limited, but because it keeps the core simple and extensible. You can build anything from a small prototype to a full-featured web application. Flask doesn’t impose strict requirements on project structure or dependencies. Here is a list of some features.
- Routing: Easily map URLs to Python functions using the @app.route() decorator.
- Templates: Use Jinja2 templating to dynamically generate HTML (render_template()).
- Request Handling: Access query parameters, form inputs, JSON data with request.
- Modular: Add only what you need — like SQLAlchemy for database handling or Flask-Login for authentication.
- Debug Mode: Built-in development server with real-time reloading and error reporting.
🔹 Part 1: Setup Python and Flask
✅ Step 1: Install Python (only once, and only if its not already installed)
- Go to the official Python website: 👉 https://www.python.org/downloads
- Click the yellow download button that says “Download Python 3.x.x”.
- IMPORTANT: Check the box that says Add Python to PATH before clicking Install Now.
- When it’s done, restart your computer (just in case!).
✅ Step 2: Open the Terminal
- Press Windows key, type cmd, and hit Enter.
- You’ll see a black window — this is the Command Prompt. You’re ready to talk to your computer 💬
✅ Step 3: Install Flask
In the Command Prompt window, type this:
pip install flask
Wait a moment — it will install Flask. You’ll see a bunch of lines. If it ends without errors, you’re good!
🔹 Part 2: Create Your Web App
✅ Step 4: Create a New Folder
- On your desktop, right-click > New > Folder → Name it flask_hello
- Open it, and right-click inside → New > Text Document
- Rename it to: app.py (make sure it’s not app.py.txt)
✅ Step 5: Write Your Python Web App
- Right-click app.py → Open with → Notepad (or Notepad++)
- Copy & paste this code:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, World! This is my first web app!'
if __name__ == '__main__':
app.run(debug=True)
Click File > Save
🔹 Part 3: Run Your Webpage
✅ Step 6: Run Your Flask App
Back in your Command Prompt, type:
cd Desktop\flask_hello
Then type:
python app.py
You will see in the command prompt
Running on http://127.0.0.1:5000/
✅ Step 7: View It in the Browser
- Open your browser (Edge, Chrome, etc.)
- Type in the address bar: 👉 http://127.0.0.1:5000/
- 🎉 You’ll see: “Hello, World! This is my first web app!”
You just ran a tiny server on your own computer. Flask gave you a webpage when you went to a URL (localhost). You can now create more routes (pages), or templates (HTML files), step by step!