Skip to content

Introduction

Flask is a lightweight web framework written in Python that provides only basic capabilities such as routing, request/response, and template rendering. Other features are selected as needed through the extension ecosystem, following the design philosophy of "micro-kernel, pluggable."

Features:

  • Lightweight: Minimal by default, retaining only necessary abstractions
  • Flexible: No enforced project structure, suitable for gradual evolution from small to large
  • Rich Ecosystem: Extensions like SQLAlchemy, WTForms, Flask-Login, Flask-Migrate, etc.
  • Complete Documentation: Beginner-friendly, quick to get started

Use Cases:

  • Prototype validation, internal tools, backend management, REST APIs, small to medium-sized services
  • Can also support more complex systems through proper engineering and extensions

Comparison with Django (brief):

  • Flask: Micro-framework, combine as needed; Django: Large and comprehensive, integrated solution
  • Flask: More freedom, gentle learning curve; Django: Stronger standardization, more built-in components

Core Components:

  • Werkzeug: WSGI utility library (routing, requests, responses)
  • Jinja2: Template engine

Hello, Flask:

python
from flask import Flask

app = Flask(__name__)

@app.get("/")
def hello():
    return "Hello, Flask!"

if __name__ == "__main__":
    app.run(debug=True)

Content is for learning and research only.