万本电子书0元读

万本电子书0元读

顶部广告

Mastering Flask电子书

售       价:¥

7人正在读 | 0人评论 9.8

作       者:Jack Stouffer

出  版  社:Packt Publishing

出版时间:2015-09-30

字       数:167.9万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Gain expertise in Flask to create dynamic and powerful web applications About This Book Work with scalable Flask application structures to create complex web apps Discover the most powerful Flask extensions and learn how to create one Deploy your application to real-world platforms using this step-by-step guide Who This Book Is For If you are a Flask user who knows the basics of the library and how to create basic web pages with HTML and CSS, and you want to take your applications to the next level, this is the book for you. Harnessing the full power of Flask will allow you to create complex web applications with ease. 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 In Detail 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. Style and approach With plenty of useful examples, this guide introduces new concepts and then shows you how those concepts can be used in a real-world environment. Most sections are based around a single example app that is developed throughout the book.
目录展开

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

Facebook

Twitter

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

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部