# Patterns for Flask

Certain things are common enough that the chances are high you will find them in most web applications. For example quite a lot of applications are using relational databases and user authentication. In that case, chances are they will open a database connection at the beginning of the request and get the information of the currently logged in user. At the end of the request, the database connection is closed again.

There are more user contributed snippets and patterns in the Flask Snippet Archives.

- Larger Applications
  - Simple Packages
  - Working with Blueprints
- Application Factories
  - Basic Factories
  - Factories & Extensions
  - Using Applications
  - Factory Improvements
- Application Dispatching
  - Working with this Document
  - Combining Applications
  - Dispatch by Subdomain
  - Dispatch by Path
- Implementing API Exceptions
  - Simple Exception Class
  - Registering an Error Handler
  - Usage in Views
- Using URL Processors
  - Internationalized Application URLs
  - Internationalized Blueprint URLs
- Deploying with Setuptools
  - Basic Setup Script
  - Tagging Builds
  - Distributing Resources
  - Declaring Dependencies
  - Installing / Developing
- Deploying with Fabric
  - Creating the first Fabfile
  - Running Fabfiles
  - The WSGI File
  - The Configuration File
  - First Deployment
  - Next Steps
- Using SQLite 3 with Flask
  - Connect on Demand
  - Easy Querying
  - Initial Schemas
- SQLAlchemy in Flask
  - Flask-SQLAlchemy Extension
  - Declarative
  - Manual Object Relational Mapping
  - SQL Abstraction Layer
- Uploading Files
  - A Gentle Introduction
  - Improving Uploads
  - Upload Progress Bars
  - An Easier Solution
- Caching
  - Setting up a Cache
  - Using a Cache
- View Decorators
  - Login Required Decorator
  - Caching Decorator
  - Templating Decorator
  - Endpoint Decorator
- Form Validation with WTForms
  - The Forms
  - In the View
  - Forms in Templates
- Template Inheritance
  - Base Template
  - Child Template
- Message Flashing
  - Simple Flashing
  - Flashing With Categories
  - Filtering Flash Messages
- AJAX with jQuery
  - Loading jQuery
  - Where is My Site?
  - JSON View Functions
  - The HTML
- Custom Error Pages
  - Common Error Codes
  - Error Handlers
- Lazily Loading Views
  - Converting to Centralized URL Map
  - Loading Late
- MongoKit in Flask
  - Declarative
  - PyMongo Compatibility Layer
- Adding a favicon
  - See also
- Streaming Contents
  - Basic Usage
  - Streaming from Templates
  - Streaming with Context
- Deferred Request Callbacks
  - The Decorator
  - Calling the Deferred
  - A Practical Example
- Adding HTTP Method Overrides
- Request Content Checksums
- Celery Based Background Tasks
  - Installing Celery
  - Configuring Celery
  - Minimal Example
  - Running the Celery Worker
- Subclassing Flask