Introduction to Flask
Flask is a lightweight WSGI web application framework in Python. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web frameworks.
1 Micro-Framework Philosophy
Flask is classified as a micro-framework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. Instead, Flask supports extensions that can add application features as if they were implemented in Flask itself.
2 Why Choose Flask?
- Simple and Flexible: Only minimal boilerplate code is required to start a working server.
- Developer Control: You decide how to structure your app, which database to use, and how to validate inputs.
- Extensible: Huge ecosystem of extensions (Flask-SQLAlchemy, Flask-Login, Flask-Migrate, etc.).
- Great for Microservices: Low overhead makes it perfect for lightweight APIs and microservice architectures.
3 Code Challenge
Challenge: Write down a short comparison of Flask and Django in your own words, explaining when you would prefer to use a micro-framework.