售 价:¥
9.8
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐

Mastering Flask
Table of Contents
Mastering Flask
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started
Version control with Git
Installing Git
Git on Windows
Git basics
Python package management with pip
Installing the pip Python package manager on Windows
Installing the pip Python package manager on Mac OS X and Linux
pip basics
Dependency sandboxing with virtualenv
virtualenv basics
The beginning of our project
Using Flask Script
Summary
2. Creating Models with SQLAlchemy
Setting up SQLAlchemy
Python packages
Flask SQLAlchemy
Our first model
Creating the user table
CRUD
Creating models
Reading models
Filtering queries
Updating models
Deleting models
Relationships between models
One-to-many
Many-to-many
The convenience of SQLAlchemy sessions
Database migrations with Alembic
Summary
3. Creating Views with Templates
Jinja's syntax
Filters
default
escape
float
int
join
length
round
safe
title
tojson
truncate
Custom filters
Comments
if statements
Loops
Macros
Flask-specific variables and functions
config
request
session
url_for()
get_flashed_messages()
Creating our views
The view function
Writing the templates and inheritance
The home page template
Writing the other templates
Flask WTForms
WTForms basics
Custom validators
Posting comments
Summary
4. Creating Controllers with Blueprints
Request setup, teardown, and application globals
Error pages
Class-based views
Method class views
Blueprints
Summary
5. Advanced Application Structure
The project as a module
Refactoring the code
Application factories
Summary
6. Securing Your App
Setting up
Updating the models
Creating the forms
Protecting your form from spam with reCAPTCHA
Creating views
Social logins
OpenID
Using the session
Flask Login
User roles
Summary
7. Using NoSQL with Flask
Types of NoSQL databases
Key-value stores
Document stores
Column family stores
Graph databases
RDBMS versus NoSQL
The strengths of RDBMS databases
Data safety
Speed and scale
Tools
The strengths of NoSQL databases
What database to use when
MongoDB in Flask
Installing MongoDB
Setting Up MongoEngine
Defining documents
Field types
Types of documents
The meta attribute
CRUD
Create
Write safety
Read
Filtering
Update
Delete
Relationships in NoSQL
One-to-many relationships
Many-to-many relationships
Leveraging the power of NoSQL
Summary
8. Building RESTful APIs
What is REST
Setting up a RESTful Flask API
GET requests
Output formatting
Request arguments
POST requests
Authentication
PUT requests
DELETE requests
Summary
9. Creating Asynchronous Tasks with Celery
What is Celery?
Setting up Celery and RabbitMQ
Creating tasks in Celery
Running Celery tasks
Celery workflows
Partials
Callbacks
Group
Chain
Chord
Running tasks periodically
Monitoring Celery
Web-based monitoring with Flower
Creating a reminder app
Creating a weekly digest
Summary
10. Useful Flask Extensions
Flask Script
Flask Debug Toolbar
Flask Cache
Caching views and functions
Caching functions with parameters
Caching routes with query strings
Using Redis as a cache backend
Using memcached as a cache backend
Flask Assets
Flask Admin
Creating basic admin pages
Creating database admin pages
Enhancing the post's administration
Creating file system admin pages
Securing Flask Admin
Flask Mail
Summary
11. Building Your Own Extension
Creating a YouTube Flask extension
Creating a Python package
Modifying the response with Flask extensions
Summary
12. Testing Flask Apps
What are unit tests?
How does testing work?
Unit testing the application
Testing the route functions
User interface testing
Test coverage
Test-driven development
Summary
13. Deploying Flask Apps
Deploying on your own server
Pushing code to your server with fabric
Running your web server with supervisor
Gevent
Tornado
Nginx and uWSGI
Apache and uWSGI
Deploying on Heroku
Using Heroku Postgres
Using Celery on Heroku
Deploying on Amazon web services
Using Flask on Amazon Elastic Beanstalk
Using Amazon Relational Database Service
Using Celery with Amazon Simple Queue Service
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜