O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Flask: Building Python Web Services

Book Description

Unleash the full potential of the Flask web framework by creating small to large and powerful web applications

About This Book

  • Create your own world-class applications and master the art of Flask by unravelling its enigma through this journey
  • Packed with recipes containing lots of sample applications to help you understand the intricacies of Flask web programming
  • Work with scalable Flask application structures to create complex web apps

Who This Book Is For

This learning path is ideal developers who know the basics of Python and want to learn how to use the Flask framework to build powerful web solutions in Python.

What You Will Learn

  • Build three web applications from the ground up using the powerful Python micro framework, Flask.
  • Extend your applications to build advanced functionality, such as a user account control system using Flask-Login
  • Learn about web application security and defend against common attacks, such as SQL injection and XSS
  • Integrate with technologies like Redis, Sentry, MongoDB and so on
  • Build applications with integrations to most of the login mechanisms available
  • Don't just stop at development. Learn about deployment and post-deployment
  • Use SQLAlchemy to programmatically query a database
  • Develop a custom Flask extension

In Detail

Are you a fan of Python? Want to use it to create powerful web applications? Then Flask is the perfect choice for you. This course will take you through the intricacies of the Flask Microframework, covering all it's components and elements and how to integrate it with useful third party libraries. Dive deep into what Flask has to offer and then you will create multiple Python apps from scratch on your own.

The first module will introduce you to web development using Flask to building fully functional web applications. Hands-on and pragmatic, this tutorial goes right to the crux of Flask by showing you how to build challenging real-world applications.

The second module introduces you to a number of recipes that will help you understand the power of Flask and its extensions. Start by seeing the different configurations that a Flask application can make use of. By the end of this module, you will have gained all the knowledge required to write Flask applications in the best possible way, and scale them with best practices.

The final module will walk you through advanced Flask topics while providing practical examples of for all your lessons learned. The module closes with a discussion of the different platforms that are available to deploy a Flask app on, the pros and cons of each one, and how to deploy on each one.

This Learning Path combines some of the best that Packt has to offer in one complete, curated package. It includes content from the following Packt products:

  • Flask By-Example: Gareth Dwyer
  • Flask Framework Cookbook: Shalabh Aggarwal
  • Mastering Flask: Jack Stouffer

Style and approach

Filled with practical examples and recipes, this course is a great combination of example-driven learning complemented by exciting techniques to build powerful Python web applications with the Flask framework

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Flask: Building Python Web Services
    1. Table of Contents
    2. Flask: Building Python Web Services
    3. Flask: Building Python Web Services
    4. Credits
    5. Preface
      1. What this learning path covers
      2. What you need for this learning path
      3. Who this learning path is for
      4. Reader feedback
        1. Customer support
        2. Downloading the example code
        3. Errata
        4. Piracy
        5. Questions
    6. 1. Module 1
      1. 1. Hello, World!
        1. Introducing Flask
        2. Creating our development environment
          1. Installing pip
          2. Installing Flask
        3. Writing "Hello, World!"
          1. Writing the code
          2. Running the code
        4. Deploying our application to production
          1. Setting up a Virtual Private Server
          2. Configuring our server
          3. Installing and using Git
          4. Serving our Flask app with WSGI
            1. Configuring Apache to serve our Flask application
        5. Summary
      2. 2. Getting Started with Our Headlines Project
        1. Setting up our project and a Git repository
        2. Creating a new Flask application
        3. Introduction to RSS and RSS feeds
          1. Using RSS from Python
          2. URL routing in Flask
          3. Publishing our Headlines application
        4. Summary
      3. 3. Using Templates in Our Headlines Project
        1. Introducing Jinja
        2. Basic use of Jinja templates
          1. Rendering a basic template
          2. Passing dynamic data to our template
          3. Displaying dynamic data in our template
        3. Advanced use of Jinja templates
          1. Using Jinja objects
          2. Adding looping logic to our template
          3. Adding hyperlinks to our template
          4. Pushing our code to the server
        4. Summary
      4. 4. User Input for Our Headlines Project
        1. Getting user input using HTTP GET
        2. Getting user input using HTTP POST
          1. Creating a branch in Git
          2. Adding POST routes in Flask
          3. Making our HTML form use POST
          4. Reverting our Git repository
        3. Adding weather and currency data
          1. Introducing the OpenWeatherMap API
            1. Signing up with OpenWeatherMap
          2. Retrieving your OpenWeatherMap API key
          3. Parsing JSON with Python
          4. Introducing JSON
          5. Retrieving and parsing JSON in Python
          6. Using our weather code
          7. Displaying the weather data
          8. Allowing the user to customize the city
            1. Adding another search box to our template
            2. Using the user's city search in our Python code
          9. Checking our new functionality
          10. Handling duplicate city names
          11. Currency
            1. Getting an API key for the Open Exchange Rates API
            2. Using the Open Exchange Rates API
            3. Using our currency function
            4. Displaying the currency data in our template
            5. Adding inputs for the user to select currency
            6. Creating an HTML select drop-down element
            7. Adding all the currencies to the select input
            8. Displaying the selected currency in the drop-down input
        4. Summary
      5. 5. Improving the User Experience of Our Headlines Project
        1. Adding cookies to our Headlines application
          1. Using cookies with Flask
            1. Setting cookies in Flask
            2. Retrieving cookies in Flask
              1. Writing the fallback logic to check for cookies
              2. Retrieving the cookies for other data
        2. Adding CSS to our Headlines application
          1. External, internal, and inline CSS
          2. Adding our first CSS
          3. Adding padding to our CSS
            1. Adding more styles to our CSS
            2. Adding the div tags to the template file
          4. Styling our inputs
        3. Summary
      6. 6. Building an Interactive Crime Map
        1. Setting up a new Git repository
        2. Understanding relational databases
        3. Installing and configuring MySQL on our VPS
          1. Installing MySQL on our VPS
          2. Installing Python drivers for MySQL
        4. Creating our Crime Map database in MySQL
          1. Creating a database setup script
            1. Creating the database
            2. Looking at our table columns
            3. Indexing and committing
          2. Using the database setup script
            1. Adding credentials to our setup script
            2. Running our database setup script
        5. Creating a basic database web application
          1. Setting up our directory structure
          2. Looking at our application code
          3. Looking at our SQL code
            1. Reading data
            2. Inserting data
            3. Deleting data
          4. Creating our view code
          5. Running the code on our VPS
          6. Mitigating against SQL injection
            1. Injecting SQL into our database application
            2. Mitigating against SQL injection
        6. Summary
      7. 7. Adding Google Maps to Our Crime Map Project
        1. Running a database application locally
          1. Creating a mock of our database
            1. Adding a test flag
            2. Writing the mock code
            3. Validating our expectations
        2. Adding an embedded Google Maps widget to our application
          1. Adding the map to our template
            1. Introducing JavaScript
            2. The body of our HTML code
            3. Testing and debugging
          2. Making our map interactive
            1. Adding markers
            2. Using a single marker
        3. Adding an input form for new crimes
          1. The HTML code for the form
          2. Adding external CSS to our web application
            1. Creating the CSS file in our directory structure
            2. Adding CSS code
            3. Configuring Flask to use CSS
            4. Viewing the result
            5. Publishing the result
          3. Linking the form to the backend
            1. Setting up the URL to collect POST data
            2. Adding the database methods
            3. Testing the code on the server
        4. Displaying existing crimes on our map
          1. Getting data from SQL
          2. Passing the data to our template
          3. Using the data in our template
          4. Viewing the results
        5. Summary
      8. 8. Validating User Input in Our Crime Map Project
        1. Choosing where to validate
          1. Identifying inputs that require validation
        2. Trying out an XSS example
          1. The potential of persistent XSS
        3. Validating and sanitizing
          1. White and blacklisting
          2. Validating versus sanitizing
          3. Implementing validation
          4. Validating the category
          5. Validating the location
          6. Validating the date
          7. Validating the description
        4. Summary
      9. 9. Building a Waiter Caller App
        1. Setting up a new Git repository
          1. Setting up the new project locally
          2. Setting up the project on our VPS
        2. Using Bootstrap to kick-start our application
          1. Introducing Bootstrap
          2. Downloading Bootstrap
            1. Bootstrap templates
        3. Adding user account control to our application
          1. Introducing Flask-Login
          2. Installing and importing Flask-Login
          3. Using Flask extensions
          4. Adding a restricted route
          5. Authenticating a user
            1. Creating a user class
          6. Mocking our database for users
          7. Logging in a user
            1. Adding imports and configuration
            2. Adding the login functionality
              1. Writing the login function
              2. Creating the load_user function
            3. Checking the login functionality
          8. Logging out a user
          9. Registering a user
            1. Managing passwords with cryptographic hashes
              1. Python hashlib
              2. Reversing hashes
              3. Salting passwords
            2. Implementing secure password storage in Python
              1. Creating the PasswordHelper class
              2. Updating our database code
              3. Updating our application code
        4. Summary
      10. 10. Template Inheritance and WTForms in Waiter Caller Project
        1. Adding the Account and Dashboard pages
          1. Introducing Jinja templates
            1. Creating the base template
            2. Creating the dashboard template
            3. Creating the account template
            4. Creating the home template
            5. Adding the routing code
          2. Creating restaurant tables
            1. Writing the restaurant table code
              1. Adding the create table form
              2. Adding the create table route
              3. Adding the create table database code
              4. Adding the view table database code
              5. Modifying the account route to pass table data
              6. Modifying the template to show the tables
              7. Adding the delete table route to our backend code
            2. Testing the restaurant table code
        2. Shortening URLs using the bitly API
          1. Introducing Bitly
          2. Using the bitly API
          3. Getting a bitly oauth token
          4. Creating the bitlyhelper file
          5. Using the bitly module
        3. Adding functionality to handle attention requests
          1. Writing the attention request code
            1. Adding the attention request route
            2. Adding the attention request database code
            3. Add the get and delete methods for attention requests
            4. Modifying the dashboard route to use attention requests
            5. Modifying the template code to display attention requests
            6. Adding the resolve request application code
            7. Testing the attention request code
            8. Auto-refreshing the dashboard page
        4. Adding user feedback with WTForms
          1. Introducing WTForms
          2. Installing Flask-WTF
          3. Creating the registration form
          4. Rendering the registration form
            1. Updating the application code
            2. Updating the template code
            3. Testing the new form
            4. Using WTForms in our application code
            5. Displaying errors to our user
              1. Displaying the errors in our template
              2. Adding CSS for the errors
            6. Testing the final registration form
            7. Adding a successful registration notification
              1. Passing the message from the application code
              2. Using the message in the template code
          5. Modifying the login form
            1. Creating the new LoginForm in the application code
            2. Using the new LoginForm in the template
          6. Modifying the create table form
        5. Summary
      11. 11. Using MongoDB with Our Waiter Caller Project
        1. Introducing MongoDB
        2. Installing MongoDB
        3. Using the MongoDB shell
          1. Starting the MongoDB shell
          2. Running commands in the MongoDB shell
            1. Creating data with MongoDB
            2. Reading data with MongoDB
            3. Updating data with MongoDB
            4. Deleting data with MongoDB
        4. Introducing PyMongo
          1. Writing the DBHelper class
            1. Adding the user methods
            2. Adding the table methods
            3. Adding the request methods
          2. Changing the application code
        5. Testing our application in production
        6. Adding some finishing touches
          1. Adding indices to MongoDB
            1. Where do we add indices?
          2. Adding a favicon
        7. Summary
      12. A. A Sneak Peek into the Future
        1. Expanding the projects
          1. Adding a domain name
          2. Adding HTTPS
          3. E-mail confirmation for new registrations
          4. Google Analytics
          5. Scalability
        2. Expanding your Flask knowledge
          1. VirtualEnv
          2. Flask Blueprints
          3. Flask extensions
            1. Flask-SQLAlchemy
            2. Flask MongoDB extensions
              1. Flask-MongoAlchemy
              2. Flask-PyMongo
            3. Flask-MongoEngine
            4. Flask-Mail
            5. Flask-Security
            6. Other Flask extensions
        3. Expanding your web development knowledge
        4. Summary
    7. 2. Module 2
      1. 1. Flask Configurations
        1. Introduction
        2. Environment setup with virtualenv
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        3. Handling basic configurations
          1. Getting ready
          2. How to do it…
          3. How it works…
        4. Class-based settings
          1. How to do it…
          2. How it works…
        5. Organization of static files
          1. How to do it…
          2. How it works…
          3. There's more…
        6. Being deployment specific with instance folders
          1. How to do it…
          2. How it works…
        7. Composition of views and models
          1. How to do it…
          2. How it works…
          3. See also
        8. Creating a modular web app with blueprints
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        9. Making a Flask app installable using setuptools
          1. How to do it…
          2. How it works…
          3. See also
      2. 2. Templating with Jinja2
        1. Introduction
        2. Bootstrap layout
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Block composition and layout inheritance
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        4. Creating a custom context processor
          1. How to do it…
          2. See also
        5. Creating a custom Jinja2 filter
          1. How to do it…
          2. How it works…
          3. See also
        6. Creating a custom macro for forms
          1. Getting ready
          2. How to do it…
        7. Advanced date and time formatting
          1. Getting ready
          2. How to do it…
          3. See more
      3. 3. Data Modeling in Flask
        1. Introduction
        2. Creating a SQLAlchemy DB instance
          1. Getting ready
          2. How to do it…
          3. There's more…
          4. See also
        3. Creating a basic product model
          1. How to do it…
          2. How it works…
          3. See also
        4. Creating a relational category model
          1. How to do it…
          2. See also
        5. Database migration using Alembic and Flask-Migrate
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        6. Model data indexing with Redis
          1. Getting ready
          2. How to do it…
          3. How it works…
        7. Opting the NoSQL way with MongoDB
          1. Getting ready
          2. How to do it…
          3. See also
      4. 4. Working with Views
        1. Introduction
        2. Writing function-based views and URL routes
          1. Getting ready
          2. How to do it…
            1. A simple GET request
            2. A simple POST request
            3. A simple GET/POST request
          3. How it works…
          4. There's more…
        3. Class-based views
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. URL routing and product-based pagination
          1. Getting ready
          2. How to do it…
            1. Adding pagination to applications
          3. See also
        5. Rendering to templates
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        6. Dealing with XHR requests
          1. Getting ready
          2. How to do it…
          3. How it works…
        7. Decorator to handle requests beautifully
          1. Getting ready
          2. How to do it…
          3. See also
        8. Creating custom 404 and 500 handlers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        9. Flashing messages for better user feedback
          1. Getting ready
          2. How to do it…
          3. How it works…
        10. SQL-based searching
          1. Getting ready
          2. How to do it…
          3. How it works…
      5. 5. Webforms with WTForms
        1. Introduction
        2. SQLAlchemy model data as form representation
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Validating fields on the server side
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        4. Creating a common forms set
          1. How to do it…
          2. How it works…
        5. Creating custom fields and validation
          1. How to do it…
          2. How it works…
          3. There's more…
        6. Creating a custom widget
          1. How to do it…
          2. How it works…
          3. See also
        7. Uploading files via forms
          1. How to do it…
          2. How it works…
        8. Cross-site Request Forgery protection
          1. How to do it…
          2. How it works…
      6. 6. Authenticating in Flask
        1. Introduction
        2. Simple session-based authentication
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Authenticating using the Flask-Login extension
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Using OpenID for authentication
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Using Facebook for authentication
          1. Getting started
          2. How to do it…
          3. How it works...
        6. Using Google for authentication
          1. Getting ready
          2. How to do it…
          3. How it works…
        7. Using Twitter for authentication
          1. Getting ready
          2. How to do it…
          3. How it works…
      7. 7. RESTful API Building
        1. Introduction
        2. Creating a class-based REST interface
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Creating an extension-based REST interface
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Creating a SQLAlchemy-independent REST API
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. A complete REST API example
          1. Getting ready
          2. How to do it…
          3. See also
      8. 8. Admin Interface for Flask Apps
        1. Introduction
        2. Creating a simple CRUD interface
          1. Getting ready
          2. How to do it…
          3. How it works…
        3. Using the Flask-Admin extension
          1. Getting ready
          2. How to do it…
          3. There's more…
        4. Registering models with Flask-Admin
          1. Getting ready
          2. How to do it…
        5. Creating custom forms and actions
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. WYSIWYG for textarea integration
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        7. Creating user roles
          1. Getting ready
          2. How to do it…
          3. How it works…
      9. 9. Internationalization and Localization
        1. Introduction
        2. Adding a new language
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Lazy evaluation and the gettext/ngettext functions
          1. Getting ready
          2. How to do it…
        4. Global language-switching action
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      10. 10. Debugging, Error Handling, and Testing
        1. Introduction
        2. Setting up basic file logging
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Sending e-mails on the occurrence of errors
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        4. Using Sentry to monitor exceptions
          1. Getting ready
          2. How to do it…
          3. How it works…
        5. Debugging with pdb
          1. Getting ready
          2. How to do it…
          3. See also
        6. Creating our first simple test
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        7. Writing more tests for views and logic
          1. Getting ready
          2. How to do it…
          3. How it works…
        8. Nose library integration
          1. Getting ready
          2. How to do it…
          3. See also
        9. Using mocking to avoid real API access
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        10. Determining test coverage
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        11. Using profiling to find bottlenecks
          1. Getting ready
          2. How to do it…
          3. How it works…
      11. 11. Deployment and Post Deployment
        1. Introduction
        2. Deploying with Apache
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Deploying with uWSGI and Nginx
          1. Getting ready
          2. How to do it…
          3. See also
        4. Deploying with Gunicorn and Supervisor
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. Deploying with Tornado
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Using Fabric for deployment
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        7. S3 storage for file uploads
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        8. Deploying with Heroku
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        9. Deploying with AWS Elastic Beanstalk
          1. Getting ready
          2. How to do it…
          3. How it works…
        10. Application monitoring with Pingdom
          1. Getting ready
          2. How to do it…
          3. How it works…
        11. Application performance management and monitoring with New Relic
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      12. 12. Other Tips and Tricks
        1. Introduction
        2. Full-text search with Whoosh
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Full-text search with Elasticsearch
          1. Getting ready
          2. How to do it…
          3. How to do it…
        4. Working with signals
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. Using caching with your application
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. E-mail support for Flask applications
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        7. Understanding asynchronous operations
          1. Getting ready
          2. How to do it…
          3. How it works…
        8. Working with Celery
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
    8. 3. Module 3
      1. 1. Getting Started
        1. Version control with Git
          1. Installing Git
            1. Git on Windows
          2. Git basics
        2. Python package management with pip
          1. Installing the pip Python package manager on Windows
          2. Installing the pip Python package manager on Mac OS X and Linux
          3. pip basics
        3. Dependency sandboxing with virtualenv
          1. virtualenv basics
        4. The beginning of our project
          1. Using Flask Script
        5. Summary
      2. 2. Creating Models with SQLAlchemy
        1. Setting up SQLAlchemy
          1. Python packages
          2. Flask SQLAlchemy
        2. Our first model
          1. Creating the user table
        3. CRUD
          1. Creating models
          2. Reading models
            1. Filtering queries
          3. Updating models
          4. Deleting models
        4. Relationships between models
          1. One-to-many
          2. Many-to-many
        5. The convenience of SQLAlchemy sessions
        6. Database migrations with Alembic
        7. Summary
      3. 3. Creating Views with Templates
        1. Jinja's syntax
          1. Filters
            1. default
            2. escape
            3. float
            4. int
            5. join
            6. length
            7. round
            8. safe
            9. title
            10. tojson
            11. truncate
            12. Custom filters
          2. Comments
          3. if statements
          4. Loops
          5. Macros
          6. Flask-specific variables and functions
            1. config
            2. request
            3. session
            4. url_for()
            5. get_flashed_messages()
        2. Creating our views
          1. The view function
          2. Writing the templates and inheritance
            1. The home page template
            2. Writing the other templates
        3. Flask WTForms
          1. WTForms basics
          2. Custom validators
          3. Posting comments
        4. Summary
      4. 4. Creating Controllers with Blueprints
        1. Request setup, teardown, and application globals
        2. Error pages
        3. Class-based views
          1. Method class views
        4. Blueprints
        5. Summary
      5. 5. Advanced Application Structure
        1. The project as a module
          1. Refactoring the code
        2. Application factories
        3. Summary
      6. 6. Securing Your App
        1. Setting up
          1. Updating the models
          2. Creating the forms
            1. Protecting your form from spam with reCAPTCHA
          3. Creating views
          4. Social logins
            1. OpenID
            2. Facebook
            3. Twitter
        2. Using the session
        3. Flask Login
          1. User roles
        4. Summary
      7. 7. Using NoSQL with Flask
        1. Types of NoSQL databases
          1. Key-value stores
          2. Document stores
          3. Column family stores
          4. Graph databases
        2. RDBMS versus NoSQL
          1. The strengths of RDBMS databases
            1. Data safety
            2. Speed and scale
            3. Tools
          2. The strengths of NoSQL databases
          3. What database to use when
        3. MongoDB in Flask
          1. Installing MongoDB
          2. Setting Up MongoEngine
          3. Defining documents
            1. Field types
            2. Types of documents
            3. The meta attribute
          4. CRUD
            1. Create
              1. Write safety
            2. Read
              1. Filtering
            3. Update
            4. Delete
          5. Relationships in NoSQL
            1. One-to-many relationships
            2. Many-to-many relationships
        4. Leveraging the power of NoSQL
        5. Summary
      8. 8. Building RESTful APIs
        1. What is REST
        2. Setting up a RESTful Flask API
        3. GET requests
          1. Output formatting
          2. Request arguments
        4. POST requests
          1. Authentication
        5. PUT requests
        6. DELETE requests
        7. Summary
      9. 9. Creating Asynchronous Tasks with Celery
        1. What is Celery?
        2. Setting up Celery and RabbitMQ
        3. Creating tasks in Celery
        4. Running Celery tasks
          1. Celery workflows
            1. Partials
            2. Callbacks
            3. Group
            4. Chain
            5. Chord
            6. Running tasks periodically
        5. Monitoring Celery
          1. Web-based monitoring with Flower
        6. Creating a reminder app
        7. Creating a weekly digest
        8. Summary
      10. 10. Useful Flask Extensions
        1. Flask Script
        2. Flask Debug Toolbar
        3. Flask Cache
          1. Caching views and functions
          2. Caching functions with parameters
          3. Caching routes with query strings
          4. Using Redis as a cache backend
          5. Using memcached as a cache backend
        4. Flask Assets
        5. Flask Admin
          1. Creating basic admin pages
          2. Creating database admin pages
          3. Enhancing the post's administration
          4. Creating file system admin pages
          5. Securing Flask Admin
        6. Flask Mail
        7. Summary
      11. 11. Building Your Own Extension
        1. Creating a YouTube Flask extension
          1. Creating a Python package
        2. Modifying the response with Flask extensions
        3. Summary
      12. 12. Testing Flask Apps
        1. What are unit tests?
        2. How does testing work?
        3. Unit testing the application
          1. Testing the route functions
        4. User interface testing
        5. Test coverage
        6. Test-driven development
        7. Summary
      13. 13. Deploying Flask Apps
        1. Deploying on your own server
          1. Pushing code to your server with fabric
          2. Running your web server with supervisor
          3. Gevent
          4. Tornado
          5. Nginx and uWSGI
          6. Apache and uWSGI
        2. Deploying on Heroku
          1. Using Heroku Postgres
          2. Using Celery on Heroku
        3. Deploying on Amazon web services
          1. Using Flask on Amazon Elastic Beanstalk
          2. Using Amazon Relational Database Service
          3. Using Celery with Amazon Simple Queue Service
        4. Summary
    9. Bibliography
    10. Index