Mastering Flask

Gain expertise in Flask to create dynamic and powerful web applications

Mastering Flask

This ebook is included in a Mapt subscription
Jack Stouffer

4 customer reviews
Gain expertise in Flask to create dynamic and powerful web applications
$0.00
$39.99
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781784393656
Paperback288 pages

Book Description

Flask is a library that allows programmers to create web applications in Python. Flask is a micro-framework that boasts a low learning curve, a large community, and the power to create complex web apps. However, Flask is easy to learn but difficult to master.

Starting from a simple Flask app, this book will walk through advanced topics while providing practical examples of the lessons learned. After building a simple Flask app, a proper app structure is demonstrated by transforming the app to use a Model-View-Controller (MVC) architecture. With a scalable structure in hand, the next chapters use Flask extensions to provide extra functionality to the app, including user login and registration, NoSQL querying, a REST API, an admin interface, and more. Next, you’ll discover how to use unit testing to take the guesswork away from making sure the code is performing as it should. The book 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.

Table of Contents

Chapter 1: Getting Started
Version control with Git
Python package management with pip
Dependency sandboxing with virtualenv
The beginning of our project
Summary
Chapter 2: Creating Models with SQLAlchemy
Setting up SQLAlchemy
Our first model
CRUD
Relationships between models
The convenience of SQLAlchemy sessions
Database migrations with Alembic
Summary
Chapter 3: Creating Views with Templates
Jinja's syntax
Creating our views
Flask WTForms
Summary
Chapter 4: Creating Controllers with Blueprints
Request setup, teardown, and application globals
Error pages
Class-based views
Blueprints
Summary
Chapter 5: Advanced Application Structure
The project as a module
Application factories
Summary
Chapter 6: Securing Your App
Setting up
Using the session
Flask Login
Summary
Chapter 7: Using NoSQL with Flask
Types of NoSQL databases
RDBMS versus NoSQL
MongoDB in Flask
Leveraging the power of NoSQL
Summary
Chapter 8: Building RESTful APIs
What is REST
Setting up a RESTful Flask API
GET requests
POST requests
PUT requests
DELETE requests
Summary
Chapter 9: Creating Asynchronous Tasks with Celery
What is Celery?
Setting up Celery and RabbitMQ
Creating tasks in Celery
Running Celery tasks
Monitoring Celery
Creating a reminder app
Creating a weekly digest
Summary
Chapter 10: Useful Flask Extensions
Flask Script
Flask Debug Toolbar
Flask Cache
Flask Assets
Flask Admin
Flask Mail
Summary
Chapter 11: Building Your Own Extension
Creating a YouTube Flask extension
Modifying the response with Flask extensions
Summary
Chapter 12: Testing Flask Apps
What are unit tests?
How does testing work?
Unit testing the application
User interface testing
Test coverage
Test-driven development
Summary
Chapter 13: Deploying Flask Apps
Deploying on your own server
Deploying on Heroku
Deploying on Amazon web services
Summary

What You Will Learn

  • Set up a best practices Python environment
  • Use SQLAlchemy to programmatically query a database
  • Develop templates in Jinja
  • Set up an MVC environment for Flask
  • Discover NoSQL, when to use it, when not to, and how to use it
  • Develop a custom Flask extension
  • Use Celery to create asynchronous tasks

Authors

Table of Contents

Chapter 1: Getting Started
Version control with Git
Python package management with pip
Dependency sandboxing with virtualenv
The beginning of our project
Summary
Chapter 2: Creating Models with SQLAlchemy
Setting up SQLAlchemy
Our first model
CRUD
Relationships between models
The convenience of SQLAlchemy sessions
Database migrations with Alembic
Summary
Chapter 3: Creating Views with Templates
Jinja's syntax
Creating our views
Flask WTForms
Summary
Chapter 4: Creating Controllers with Blueprints
Request setup, teardown, and application globals
Error pages
Class-based views
Blueprints
Summary
Chapter 5: Advanced Application Structure
The project as a module
Application factories
Summary
Chapter 6: Securing Your App
Setting up
Using the session
Flask Login
Summary
Chapter 7: Using NoSQL with Flask
Types of NoSQL databases
RDBMS versus NoSQL
MongoDB in Flask
Leveraging the power of NoSQL
Summary
Chapter 8: Building RESTful APIs
What is REST
Setting up a RESTful Flask API
GET requests
POST requests
PUT requests
DELETE requests
Summary
Chapter 9: Creating Asynchronous Tasks with Celery
What is Celery?
Setting up Celery and RabbitMQ
Creating tasks in Celery
Running Celery tasks
Monitoring Celery
Creating a reminder app
Creating a weekly digest
Summary
Chapter 10: Useful Flask Extensions
Flask Script
Flask Debug Toolbar
Flask Cache
Flask Assets
Flask Admin
Flask Mail
Summary
Chapter 11: Building Your Own Extension
Creating a YouTube Flask extension
Modifying the response with Flask extensions
Summary
Chapter 12: Testing Flask Apps
What are unit tests?
How does testing work?
Unit testing the application
User interface testing
Test coverage
Test-driven development
Summary
Chapter 13: Deploying Flask Apps
Deploying on your own server
Deploying on Heroku
Deploying on Amazon web services
Summary

Book Details

ISBN 139781784393656
Paperback288 pages
Read More
From 4 reviews

Read More Reviews