You are here: Home Books f Flask Web Development
Document Actions

Flask Web Development

Developing Web Applications with Python

Miguel Grinberg

Publisher: O'Reilly, 2014 , 237 pages

ISBN: 978-1-449-37262-0

Keywords: Python, Web Programming


Toggle Synopsis

Take full creative control of your web applications with Flask, the Python-based microframework. With this hands-on book, you’ll learn Flask from the ground up by developing a complete social blogging application step-by-step. Author Miguel Grinberg walks you through the framework’s core functionality, and shows you how to extend applications with advanced web techniques such as database migration and web service communication.

Rather than impose development guidelines as other frameworks do, Flask leaves the business of extensions up to you. If you have Python experience, this book shows you how to take advantage of that creative freedom.

  • Learn Flask’s basic application structure and write an example app
  • Work with must-have components — templates, databases, web forms, and email support
  • Use packages and modules to structure a large application that scales
  • Implement user authentication, roles, and profiles
  • Build a blogging feature by reusing templates, paginating item lists, and working with rich text
  • Use a Flask-based RESTful API to expose app functionality to smartphones, tablets, and other third-party clients
  • Learn how to run unit tests and enhance application performance
  • Explore options for deploying your web app to a production server

Table of Contents:

Toggle Table of Contents

  • Part I: Introduction to Flask
    1. Installation
      • Using Virtual Environments
      • Installing Python Packages with pip
    2. Basic Application Structure
      • Initialization
      • Routes and View Functions
      • Server Startup
      • A Complete Application
      • The Request-Response Cycle
        • Application and Request Contexts
        • Request Dispatching
        • Request Hooks
        • Responses
      • Flask Extensions
        • Command-Line Options with Flask-Script
    3. Templates
      • The Jinja2 Template Engine
        • Rendering Templates
        • Variables
        • Control Structures
      • Twitter Bootstrap Integration with Flask-Bootstrap
      • Custom Error Pages
      • Links
      • Static Files
      • Localization of Dates and Times with Flask-Moment
    4. Web Forms
      • Cross-Site Request Forgery (CSRF) Protection
      • Form Classes
      • HTML Rendering of Forms
      • Form Handling in View Functions
      • Redirects and User Sessions
      • Message Flashing
    5. Databases
      • SQL Databases
      • NoSQL Databases
      • SQL or NoSQL?
      • Python Database Frameworks
      • Database Management with Flask-SQLAlchemy
      • Model Definition
      • Relationships
      • Database Operations
        • Creating the Tables
        • Inserting Rows
        • Modifying Rows
        • Deleting Rows
        • Querying Rows
      • Database Use in View Functions
      • Integration with the Python Shell
      • Database Migrations with Flask-Migrate
        • Creating a Migration Repository
        • Creating a Migration Script
        • Upgrading the Database
    6. Emails
      • Email Support with Flask-Mail
        • Sending Email from the Python Shell
        • Integrating Emails with the Applications
        • Sending Asynchronous Email
    7. Large Application Structure
      • Project Structure
      • Configuration Options
      • Application Package
        • Using an Application Factory
        • Implementing Application Functionality in a Blueprint
      • Launch Script
      • Requirements File
      • Unit Tests
      • Database Setup
  • Part II: Example: A Social Blogging Application
    1. User Authentication
      • Authentication Extensions for Flask
      • Password Security
        • Hashing Passwords with Werkzeug
      • Creating an Authentication Blueprint
      • User Authentication with Flask-Login
        • Preparing the User Model for Logins
        • Protecting Routes
        • Adding a Login Form
        • Signing Users In
        • Signing Users Out
        • Testing Logins
      • New User Registration
        • Adding a User Registration Form
        • Registering New Users
      • Account Confirmation
        • Generating Confirmation Tokens with itsdangerous
        • Sending Confirmation Emails
      • Account Management
    2. User Roles
      • Database Representation of Roles
      • Role Assignment
      • Role Verification
    3. User Profiles
      • Profile Information
      • User Profile Page
      • Profile Editor
        • Upper-Level Profile Editor
        • Administrator-Level Profile Editor
      • User Avatars
    4. Blog Posts
      • Blog Post Submission and Display
      • Blog Posts in Profile Pages
      • Paginating Long Lists of Blog Posts
        • Creating Fake Blog Post Data
        • Rendering Data on Pages
        • Adding a Pagination Widget
      • Rich-Text Posts with Markdown and Flask-PageDown
        • Using Flask-PageDown
        • Handling Rich Text on the Server
      • Permanent Links to Blog Posts
      • Blog Post Editor
      • Database Relationships Revisited
        • Many-to-Many Relationships
        • Self-Referential Relationships
        • Advanced Many-to-Many Relationships
      • Followers on the Profile Page
      • Query Followed Posts using a Database Join
      • Show Followed Posts on the Home Page
    6. User Comments
      • Database Representation of Comments
      • Comment Submission and Display
      • Comment Moderation
    7. Application Programming Interfaces (APIs)
      • Introduction to REST
        • Resources Are Everything
        • Request Methods
        • Request and Response Bodies
        • Versioning
      • RESTful Web Services with Flask
        • Creating an API Blueprint
        • Error Handling
        • User Authentication with Flask-HTTPAuth
        • Token-Based Authentication
        • Serializing Resources to and from JSON
        • Implementing Resource Endpoints
        • Pagination of Large Resource Collections
        • Testing Web Services with HTTPie
  • Part III: The Last Mile
    1. Testing
      • Obtaining Code Coverage Reports
      • The Flask Test Client
        • Testing Web Applications
        • Testing Web Services
      • End-to-End Testing with Selenium
      • Is It Worth It?
    2. Performance
      • Logging Slow Database Performance
      • Source Code Profiling
    3. Deployment
      • Deployment Workflow
      • Logging of Errors In Production
      • Cloud Deployment
      • The Heroku Platform
        • Preparing the Application
        • Testing with Foreman
        • Enabling Secure HTTP with Flask-SSLify
        • Deploying with git push
        • Reviewing Logs
        • Deploying an Upgrade
      • Traditional Hosting
        • Server Setup
        • Importing Environment Variables
        • Setting Up Logging
    4. Additional Resources
      • Using an Integrated Development Environment
      • Finding Flask Extensions
      • Getting Involved with Flask


Flask Web Development

by Roland Buresund last modified 2015-12-21 23:16

Rating: ******** (Very good)

Based on the authors popular blog-tutorial. It is very good, but I believe it fits better as an online-tutorial.

With that said, it still has some very good, practical points and has to be considered recommended reading if you intend to program in Flask. But check out the errata first, otherwise you'll get confused when some stuff doesn't work.

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: