Flask is a lightweight Python web framework. It gives you routing, templating, and a dev server — then gets out of your way.
What You Get for Free
- Minimal core — only what you need
- Jinja2 templates — powerful template engine
- Werkzeug — robust WSGI toolkit underneath
- Extensions — Flask-SQLAlchemy, Flask-Login, Flask-CORS
- Blueprints — modular application components
Hello World API
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/api/hello')
def hello():
return jsonify({'message': 'Hello World'})
if __name__ == '__main__':
app.run(debug=True)
Flask vs Django
| Feature | Flask | Django |
|---|---|---|
| Philosophy | Micro | Batteries-included |
| Learning curve | Lower | Higher |
| Admin panel | No (add-on) | Built-in |
| Best for | APIs, microservices | Full web apps |
Tips
- Use Flask-RESTful or Flask-RESTX for REST APIs
- Use Gunicorn for production (not built-in server)
- Structure with Blueprints from day one
Need Python API development? Check my work on GitHub or email spinov001@gmail.com for consulting.
Top comments (0)