Description #
Flask is a lightweight, micro web framework written in Python. It provides the essentials to build web applications quickly and flexibly, while allowing developers to plug in extensions for features like authentication, databases, and more.
History #
Flask was created by Armin Ronacher and released in 2010 as an April Fool’s joke that became a serious project. Built on top of the Werkzeug toolkit and Jinja2 template engine, Flask gained popularity for its simplicity and “do one thing well” philosophy. It remains a top choice for Python developers building APIs and small-to-medium web apps.
Hello World Code #
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello, World!"
if __name__ == "__main__":
app.run()
How to Run #
Option 1: Online
Option 2: Local
Install Flask:
pip install flask
Save the code as app.py
Run:
python app.py
Key Concepts #
- Minimal and extensible framework
- URL routing and HTTP methods
- Template rendering with Jinja2
- Supports RESTful APIs
- Built-in development server
- Simple configuration
- WSGI-compliant (uses Werkzeug)
- Modular structure
- Common for microservices and prototypes
- Ideal for beginners and advanced users
Try It Online #
Fun Facts #
- Flask was inspired by Sinatra (Ruby) and Bottle (Python).
- It became popular partly because of the humorous origin as a joke framework.
- Flask is often paired with extensions like Flask-Login, Flask-SQLAlchemy, and Flask-WTF.