售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Flask Framework Cookbook
Table of Contents
Flask Framework Cookbook
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. Flask Configurations
Introduction
Environment setup with virtualenv
How to do it…
How it works…
There's more…
See also
Handling basic configurations
Getting ready
How to do it…
How it works…
Class-based settings
How to do it…
How it works…
Organization of static files
How to do it…
How it works…
There's more…
Being deployment specific with instance folders
How to do it…
How it works…
Composition of views and models
How to do it…
How it works…
See also
Creating a modular web app with blueprints
Getting ready
How to do it…
How it works…
See also
Making a Flask app installable using setuptools
How to do it…
How it works…
See also
2. Templating with Jinja2
Introduction
Bootstrap layout
Getting ready
How to do it…
How it works…
See also
Block composition and layout inheritance
Getting ready
How to do it…
How it works…
See also
Creating a custom context processor
How to do it…
See also
Creating a custom Jinja2 filter
How to do it…
How it works…
See also
Creating a custom macro for forms
Getting ready
How to do it…
Advanced date and time formatting
Getting ready
How to do it…
See more
3. Data Modeling in Flask
Introduction
Creating a SQLAlchemy DB instance
Getting ready
How to do it…
There's more…
See also
Creating a basic product model
How to do it…
How it works…
See also
Creating a relational category model
How to do it…
See also
Database migration using Alembic and Flask-Migrate
Getting ready
How to do it…
How it works…
See also
Model data indexing with Redis
Getting ready
How to do it…
How it works…
Opting the NoSQL way with MongoDB
Getting ready
How to do it…
See also
4. Working with Views
Introduction
Writing function-based views and URL routes
Getting ready
How to do it…
A simple GET request
A simple POST request
A simple GET/POST request
How it works…
There's more…
Class-based views
Getting ready
How to do it…
How it works…
There's more…
See also
URL routing and product-based pagination
Getting ready
How to do it…
Adding pagination to applications
See also
Rendering to templates
Getting ready
How to do it…
How it works…
See also
Dealing with XHR requests
Getting ready
How to do it…
How it works…
Decorator to handle requests beautifully
Getting ready
How to do it…
See also
Creating custom 404 and 500 handlers
Getting ready
How to do it…
How it works…
There's more…
Flashing messages for better user feedback
Getting ready
How to do it…
How it works…
SQL-based searching
Getting ready
How to do it…
How it works…
5. Webforms with WTForms
Introduction
SQLAlchemy model data as form representation
Getting ready
How to do it…
How it works…
See also
Validating fields on the server side
How to do it…
How it works…
There's more…
See also
Creating a common forms set
How to do it…
How it works…
Creating custom fields and validation
How to do it…
How it works…
There's more…
Creating a custom widget
How to do it…
How it works…
See also
Uploading files via forms
How to do it…
How it works…
Cross-site Request Forgery protection
How to do it…
How it works…
6. Authenticating in Flask
Introduction
Simple session-based authentication
Getting ready
How to do it…
How it works…
See also
Authenticating using the Flask-Login extension
Getting ready
How to do it…
How it works…
There's more…
See also
Using OpenID for authentication
Getting ready
How to do it…
How it works…
Using Facebook for authentication
Getting started
How to do it…
How it works...
Using Google for authentication
Getting ready
How to do it…
How it works…
Using Twitter for authentication
Getting ready
How to do it…
How it works…
7. RESTful API Building
Introduction
Creating a class-based REST interface
Getting ready
How to do it…
How it works…
There's more…
Creating an extension-based REST interface
Getting ready
How to do it…
How it works…
There's more…
Creating a SQLAlchemy-independent REST API
Getting ready
How to do it…
How it works…
See also
A complete REST API example
Getting ready
How to do it…
See also
8. Admin Interface for Flask Apps
Introduction
Creating a simple CRUD interface
Getting ready
How to do it…
How it works…
Using the Flask-Admin extension
Getting ready
How to do it…
There's more…
Registering models with Flask-Admin
Getting ready
How to do it…
Creating custom forms and actions
Getting ready
How to do it…
How it works…
WYSIWYG for textarea integration
Getting ready
How to do it…
How it works…
See also
Creating user roles
Getting ready
How to do it…
How it works…
9. Internationalization and Localization
Introduction
Adding a new language
Getting ready
How to do it…
How it works…
There's more…
See also
Lazy evaluation and the gettext/ngettext functions
Getting ready
How to do it…
Global language-switching action
Getting ready
How to do it…
How it works…
See also
10. Debugging, Error Handling, and Testing
Introduction
Setting up basic file logging
Getting ready
How to do it…
How it works…
There's more…
See also
Sending e-mails on the occurrence of errors
Getting ready
How to do it…
How it works…
There's more…
Using Sentry to monitor exceptions
Getting ready
How to do it…
How it works…
Debugging with pdb
Getting ready
How to do it…
See also
Creating our first simple test
Getting ready
How to do it…
How it works…
See also
Writing more tests for views and logic
Getting ready
How to do it…
How it works…
Nose library integration
Getting ready
How to do it…
See also
Using mocking to avoid real API access
Getting ready
How to do it…
How it works…
See also
Determining test coverage
Getting ready
How to do it…
How it works…
See also
Using profiling to find bottlenecks
Getting ready
How to do it…
How it works…
11. Deployment and Post Deployment
Introduction
Deploying with Apache
Getting ready
How to do it…
How it works…
There's more…
See also
Deploying with uWSGI and Nginx
Getting ready
How to do it…
See also
Deploying with Gunicorn and Supervisor
Getting ready
How to do it…
How it works…
See also
Deploying with Tornado
Getting ready
How to do it…
How it works…
Using Fabric for deployment
Getting ready
How to do it…
How it works…
There's more…
S3 storage for file uploads
Getting ready
How to do it…
How it works…
See also
Deploying with Heroku
Getting ready
How to do it…
How it works…
There's more…
Deploying with AWS Elastic Beanstalk
Getting ready
How to do it…
How it works…
Application monitoring with Pingdom
Getting ready
How to do it…
How it works…
Application performance management and monitoring with New Relic
Getting ready
How to do it…
How it works…
See also
12. Other Tips and Tricks
Introduction
Full-text search with Whoosh
Getting ready
How to do it…
How it works…
See also
Full-text search with Elasticsearch
Getting ready
How to do it…
How to do it…
Working with signals
Getting ready
How to do it…
How it works…
See also
Using caching with your application
Getting ready
How to do it…
How it works…
There's more…
See also
E-mail support for Flask applications
Getting ready
How to do it…
How it works…
There's more…
See also
Understanding asynchronous operations
Getting ready
How to do it…
How it works…
Working with Celery
Getting ready
How to do it…
How it works…
See also
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜