🐍 Python Advanced

What is Flask in Python?

Why Interviewers Ask This

Advanced questions like this reveal whether a candidate has internalized Python deeply enough to make architectural decisions. Strong answers demonstrate both breadth and depth of experience.

Answer

Flask is a lightweight, micro web framework for Python. Unlike Django's "batteries included" approach, Flask provides only the core (routing, request handling, templating with Jinja2) and lets you choose your own components. A minimal Flask app: from flask import Flask; app = Flask(__name__); @app.route("/"); def home(): return "Hello, World!". Key components: Blueprints (modular app organization), Flask-SQLAlchemy (ORM), Flask-Migrate (database migrations), Flask-Login (authentication), Flask-WTF (forms), Marshmallow (serialization). The application context (g) and request context (request, session) are thread-local proxies. Flask is excellent for microservices, APIs, and projects where Django's conventions would be overkill. FastAPI is a modern alternative to Flask with automatic API documentation, async support, and Pydantic integration.

Pro Tip

Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Python codebase.