What Is Flask?
Flask Microframework
Flask is a lightweight Python web microframework that gives you the basics (routing, templates, sessions) and lets you choose everything else. It's ideal for small APIs, prototypes, and applications where you want full control over your stack.
How Flask Works
Flask's philosophy is minimalism. A hello world API is 5 lines of code. Unlike Django, Flask doesn't include an ORM, admin panel, or auth — you add what you need via extensions (Flask-SQLAlchemy, Flask-Login). This makes it lighter but requires more decisions.
Key Concepts
- Minimal Core — Flask includes only routing, templates (Jinja2), and sessions — everything else is optional extensions
- Blueprints — Organize large Flask apps into modular components with their own routes and templates
- Jinja2 — Flask's template engine — dynamic HTML with Python-like syntax and template inheritance
Frequently Asked Questions
Flask vs Django for beginners?
Flask for understanding how web frameworks work (it's transparent). Django for getting productive fast (it's opinionated). Learn Flask to understand the fundamentals, then use Django or FastAPI for production.
Is Flask good for production?
Yes, with the right setup. Use Gunicorn as the WSGI server, add proper error handling, and choose extensions carefully. Pinterest started on Flask.