🌍 Python · flashcards

Python Flask Flashcards

50 question-and-answer cards covering Flask as it is examined in Python. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

50Cards in deck
24Free preview
17Syllabus topics
~217Chars per answer
FreePrice

24 sample cards from the Flask deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. Which extension manages user login sessions in Flask, and what main object/decorator does it provide?

    Flask-Login. It provides the `LoginManager`, the `current_user` proxy, `login_user()`/`logout_user()` functions, and the `@login_required` decorator to protect views.

  2. Why should passwords never be stored in plaintext, and what function pair does Werkzeug provide for hashing?

    Plaintext passwords are catastrophic if the database is breached. Werkzeug provides `generate_password_hash(password)` to store a salted hash and `check_password_hash(hash, password)` to verify on login.

  3. What four methods/properties must a Flask-Login user model implement (via UserMixin)?

    `is_authenticated`, `is_active`, `is_anonymous`, and `get_id()`. Inheriting from `UserMixin` provides default implementations of all four.

  4. What is the difference between authentication and authorization?

    Authentication verifies WHO a user is (identity, e.g. login credentials). Authorization determines WHAT an authenticated user is permitted to do (access control / roles/permissions). Authentication precedes authorization.

  5. Why is Flask's built-in development server unsuitable for production?

    It is single-threaded by default, not optimized for performance, lacks robustness/security hardening, and is not designed to handle concurrent production traffic. A dedicated WSGI server should be used instead.

  6. Name two common production WSGI servers used to run Flask apps.

    Gunicorn (Green Unicorn) and uWSGI. On Windows, Waitress is also common. These serve the Flask WSGI app with multiple workers for concurrency.

  7. In a production Flask deployment, what is the role of a reverse proxy like Nginx in front of Gunicorn?

    Nginx handles incoming HTTP connections, serves static files efficiently, terminates TLS/SSL, load-balances, buffers slow clients, and forwards dynamic requests to the Gunicorn/WSGI server, which runs the Flask app.

  8. What does the formula for sizing Gunicorn workers commonly recommend?

    A common rule of thumb is $workers = (2 \times N_{cores}) + 1$, where $N_{cores}$ is the number of CPU cores. This balances CPU utilization against I/O wait.

  9. List several hosting options for deploying a Flask application.

    PaaS (Heroku, Render, Railway, PythonAnywhere), IaaS/VPS (AWS EC2, DigitalOcean, Linode), serverless (AWS Lambda + API Gateway via Zappa), and container platforms (AWS ECS/EKS, Google Cloud Run, Kubernetes).

  10. What is the difference between PaaS and IaaS for hosting Flask?

    PaaS (Platform-as-a-Service, e.g. Heroku) manages servers, OS, and runtime—you just push code. IaaS (Infrastructure-as-a-Service, e.g. EC2) gives you raw virtual machines you must configure, secure, and maintain yourself. PaaS trades control for convenience.

  11. What is containerization and which tool is most commonly used to containerize Flask apps?

    Containerization packages an application with all its dependencies and runtime into a portable, isolated unit (container) that runs consistently across environments. Docker is the most common tool.

  12. What is a Dockerfile and name three typical instructions used when containerizing a Flask app.

    A Dockerfile is a text script of instructions to build a container image. Typical instructions: `FROM python:3.x-slim` (base image), `COPY` (add code), `RUN pip install -r requirements.txt` (deps), `EXPOSE` (port), and `CMD ["gunicorn", ...]` (start command).

  13. What is the difference between a Docker image and a Docker container?

    An image is a read-only template/blueprint built from a Dockerfile. A container is a running (or stopped) instance of an image—the live, isolated process. You can run many containers from one image.

  14. What is Docker Compose used for in a Flask project?

    Docker Compose defines and runs multi-container applications via a `docker-compose.yml` file—e.g. orchestrating the Flask app container together with a database (Postgres) and cache (Redis) containers, with networking and volumes.

  15. What is unit testing, and what does it isolate in a Flask app?

    Unit testing verifies a single, smallest piece of logic (a function or method) in isolation, mocking external dependencies. In Flask it targets individual helpers, model methods, or utility functions independent of the HTTP layer.

  16. How do you obtain a test client in Flask for testing routes without a running server?

    Call `app.test_client()`, which returns a client you can use to issue requests like `client.get('/')` or `client.post('/login', data={...})` and inspect the response (`response.status_code`, `response.data`).

  17. What is the difference between unit testing and integration testing?

    Unit testing checks one component in isolation. Integration testing verifies that multiple components work together correctly—e.g. a request hitting a route, querying the real (or test) database, and rendering a template end-to-end.

  18. Name two popular Python testing frameworks used with Flask and the assertion style each favors.

    unittest (standard library, class-based with `self.assertEqual` style assertions) and pytest (function-based, uses plain `assert` statements with rich introspection and fixtures).

  19. What is the Application Factory pattern in Flask and why is it useful?

    It is a function (e.g. `def create_app(config):`) that constructs and returns the Flask app, initializing extensions inside it. It enables multiple app instances (e.g. for testing), avoids circular imports, and supports per-environment configuration.

  20. What is a Flask Blueprint and what problem does it solve?

    A Blueprint is a way to organize a group of related routes, templates, and static files into a reusable component. It modularizes large applications and lets you register feature areas (e.g. auth, admin) onto the app, avoiding one monolithic file.

  21. List the four main ways to load configuration in Flask.

    1) `app.config.from_object('config.Config')` (object/class), 2) `app.config.from_pyfile('config.py')` (file), 3) `app.config.from_envvar('SETTINGS')` (env-referenced file), and 4) `app.config['KEY'] = value` / `from_mapping`. Often combined with environment variables for secrets.

  22. Why are class-based config objects (e.g. Development, Production) a recommended pattern?

    They allow a base `Config` class with shared defaults and subclasses (`DevelopmentConfig`, `ProductionConfig`, `TestingConfig`) overriding values like `DEBUG` and database URIs, so the right configuration is selected per environment cleanly.

  23. What is the SECRET_KEY in Flask used for, and how should it be managed?

    `SECRET_KEY` cryptographically signs session cookies and CSRF tokens, protecting them from tampering. It must be a long random value, kept secret, and loaded from an environment variable (never hardcoded or committed to version control).

  24. Name three core web security best practices a Flask application should follow.

    1) Use HTTPS/TLS and set secure session cookies (`SESSION_COOKIE_SECURE`, `HTTPONLY`, `SAMESITE`). 2) Prevent injection: use the ORM/parameterized queries (SQL injection) and rely on Jinja2 autoescaping (XSS). 3) Enable CSRF protection (Flask-WTF), hash passwords, and disable debug mode in production.

What this deck covers

The Flask deck follows the Python Flask syllabus — 6 chapters and 17 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 8.3 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 217 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

Flask flashcards FAQ

How many Flask flashcards are in this Python deck?

50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these Python flashcards free?

Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.

What do the Flask cards cover?

They follow the Python Flask syllabus — 6 chapters and 17 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.