You are here: Home Books f Flask Blueprints
Document Actions

Flask Blueprints

Dive into the world of the Flask microframework to develop an array of web applications

Joël Perras

Publisher: Packt, 2015 , 175 pages

ISBN: 978-1-78439-478-3

Keywords: Python, Web Programming


Toggle Synopsis

This book shows you how to leverage the Flask microframework, various popular Flask extensions, Python libraries, and third-party APIs to build a series of increasingly complex web applications.

The book starts by first setting the groundwork for a sane development environment using the virtualenv tool, and how to structure non-trivial Flask applications to better leverage a more modular design. You'll first build an application backed by a SQL database that uses several useful and popular Flask extensions. Next, a social news-like application is constructed and tested with the pytest set of tools. Following this, a JSON-based API-centric application is created using the Flask-RESTful extension. You'll learn ow to use HTTP authentication to secure your API, write custom WSGI middlewares, and ensure that your application is thoroughly tested. The next application shows you how to use Flask-Script to create CLI tools for interfacing with your data models via the command line. Finally, the last application does a deep-dive into the world of OAuth; database migrations with Alembic are covered briefly, setting the stage for long-term application development and sustainability when working with a team.

Table of Contents:

Toggle Table of Contents

  1. Starting on the Right Foot — Using Virtualenv
    • Setuptools and pip
    • Avoiding dependency hell, the Python way
    • Working with virtualenv
      • Creating a new virtual environment
      • Activating and deactivating virtual environments
      • Adding packages to an existing environment
      • Uninstalling packages from an existing environment
    • Simplifying common operations — using the virtualenvwrapper tool
    • Summary
  2. Small to Big — Growing the Flask Application Structure
    • Your first Flask application structure
    • From module to package
    • From package to blueprint
      • Our first blueprint
    • Summary
  3. Snap — the Code Snippet Sharing Application
    • Getting started
      • Flask-SQLAlchemy
        • Configuring Flask-SQLAlchemy
        • SQLAlchemy basics
        • Snap data models
      • Flask-Login and Flask-Bcrypt for authentication
      • Flask-WTF — form validation and rendering
        • Hashing user passwords
        • Configure an application SECRET_KEY
        • Hook up the blueprint
      • Let's run this thing
      • The data model for snaps
        • Better defaults with content-sensitive default functions
      • Snap view handlers
    • Summary
  4. Socializer — the Testable Timeline
    • Starting off
    • Application factories
      • The application context
        • Instantiating an app context
    • Unit and functional testing
    • Social features — friends and followers
    • Functional and integration testing
    • Publish/subscribe events with Blinker
      • Signals from Flask and extensions
      • Creating custom signals
    • Graceful handling of exceptions
    • Functional testing
    • Your newsfeed
    • Summary
  5. Shutterbug, the Photo Stream API
    • Starting off
    • The application factory
    • Interlude — Werkzeug
    • Simple APIs with Flask-RESTful
      • Improved password handling with hybrid attributes
      • API authentication
        • Authentication protocols
      • Getting users
        • Creating new users
        • API testing
      • Interlude — Werkzeug middlewares
        • Back to Shutterbug — uploading photos
        • Testing the photo uploads
      • Fetching the user's photos
    • Summary
  6. Hublot — Flask CLI Tools
    • Starting off
      • The file
        • The built-in commands
      • The Flask-Script commands across Blueprints
        • Submanagers
        • The required and optional arguments
      • Flask extensions — the basics
        • When should an extension be used?
        • Our extension — GitHubber
    • Summary
  7. Dinnerly — Recipe Sharing
    • First OAuth
      • Why use OAuth?
      • Terminology
      • So what's wrong with OAuth 1.0?
      • Three-legged authorization
    • Setting up the application
      • Declaring our models
      • Handling OAuth in our views
      • Creating recipes
      • Posting recipes to Twitter and Facebook
        • SQLAlchemy events
      • Finding common friends
    • Interlude — database migrations
      • Alembic
    • Summary


Flask Blueprints

by Roland Buresund last modified 2016-07-04 15:50

Rating: **** (Mediocre)

Not a bad book per se, as it contains some lucid explanations (even if the example code contains errors). But it doesn't really make you even a beginner in utilizing the Flask Blueprints.

And considering the asking price for this book (very steep for a very few pages), I would recommend you to avoid it!

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: