: Network Disk Download
Content Introduction· · · · · ·
This book is not only suitable for novice web developers to learn to read, but also a great reference book for Python programmers to learn advanced Web development techniques.
Learn the basic structure of flask application and write a sample application;
? Use the necessary components, including templates, databases, Web Forms, and e-mail support;
? Use packages and modules to build scalable, large-scale applications;
To implement user authentication, roles and personal data;
? reuse templates, paginated display lists, and rich text in blog sites;
? Use flask-based restful APIs to implement available features on smartphones, tablets, and other third-party clients;
Learn to run unit tests and improve performance;
? Deploy the Web app to the production server.
Author profile ...
Miguel Grinberg
Senior Software engineer with 25 of development experience, currently developing video software for broadcasting companies. He often writes various blogs on his personal blog (blog.miguelgrinberg.com), covering web development, robotics, photography, and occasional critics. He and his wife, four children, two dogs and a cat live together in Oregon State Portland. Twitter: @miguelgrinberg.
Catalogue ... preface XI
The first part flask introduction
1th Installation 3
1.1 Using Virtual Environments 4
1.2 Installing Python packages with PIP 6
Chapter 2nd Basic Structure of the procedure 7
2.1 Initialization 7
2.2 Routing and view functions 7
2.3 Starting Server 9
2.4 A complete program 9
2.5 Request-Response Loop 11
2.5.1 Program and request context 11
2.5.2 Request Dispatch 13
2.5.3 Request Hook 13
2.5.4 Response 14
2.6 Flask Extension 15
The 3rd Chapter template 19
3.1 Jinja2 template engine 19
3.1.1 Rendering Templates 20
3.1.2 Variable 21
3.1.3 Control Structure 22
3.2 Using Flask-bootstrap to integrate Twitter Bootstrap 23
3.3 Custom Error Page 26
3.4 Links 29
3.5 Static Files 29
3.6 using flask-moment localization date and time 30
4th Web Form 33
4.1 Cross-site request forgery Protection 33
4.2 Form Class 34
4.3 rendering the form into HTML 35
4.4 Working with Forms in view functions 37
4.5 Redirection and user session 39
4.6 Flash Message 41
5th. Database 43
5.1 SQL Database 43
5.2 NoSQL Database 44
5.3 Using SQL or NoSQL 45
5.4 Python Database Framework 45
5.5 Managing databases with Flask-sqlalchemy 46
5.6 Defining a Model 47
5.7 Relationship 49
5.8 Database Operations 50
5.8.1 Creating a Table 50
5.8.2 Insert Row 51
5.8.3 Modifying line 52
5.8.4 Deleting Rows 52
5.8.5 Query Row 52
5.9 manipulating databases in view functions 54
5.1 Set into Python shell 56
5.11 Using Flask-migrate for database Migration 56
5.11.1 Creating a migration warehouse 57
5.11.2 Creating a Migration script 57
5.11.3 Update Database 58
6th Chapter e-Mail 59
Using Flask-mail to provide email support 59
Send an email in the Python shell 60
Integrating the Send email feature in your program 61
Send an e-mail asynchronously 62
7th structure of large-scale programs 65
7.1 Project Structure 65
7.2 Configuration Options 66
7.3 Package 67
7.3.1 using program factory functions 68
7.3.2 implementation of program functions in the Blueprint 69
7.4 Startup Scripts 71
7.5 Requirements Document 71
7.6 Unit Test 72
7.7 Creating a database 74
Part Two: Social blogging programs
8th. User Authentication 77
8.1 Flask Certification Extension 77
8.2 Password Security 77
8.3 Creating the Certification Blueprint 80
8.4 Authenticating users with Flask-login 81
8.4.1 preparing the user model for login 81
8.4.2 Securing Routes 83
8.4.3 Adding a login form 83
8.4.4 Log In User 84
8.4.5 logged out users 86
8.4.6 Test Login 86
8.5 Registering a new user 87
8.5.1 Adding a user registration Form 87
8.5.2 Register a new user 89
8.6 Confirm Account 90
8.6.1 using itsdangerous to generate confirmation tokens 90
8.6.2 sending a confirmation email 92
8.7 Managing Accounts 95
9th User Role 97
9.1 Representation of roles in the database 97
9.2 Assigning a role 99
9.3 Role Verification 100
10th. User Information 103
10.1 Information 103
10.2 User Profile Page 104
10.3 Information Editor 106
10.3.1 User-level Profile Editor 106
10.3.2 Administrator-level Profile Editor 108
10.4 User Picture 110
11th. Blog post 115
11.1 Submitting and displaying a blog post 115
11.2 Displaying a blog post in the profile page 118
11.3 Pagination Display Long blog posts list 118
11.3.1 Creating a virtual blog post data 119
11.3.2 rendering data in a page 120
11.3.3 Add Pager 121
11.4 using markdown and Flask-pagedown to support Rich text articles 124
11.4.1 using Flask-pagedown 124
11.4.2 processing Rich Text on the server 125
11.5 Fixed links to blog posts 127
11.6 blog post Editor 128
12th. Followers 131
12.1 Re-discussion of database relationship 131
12.1.1 Many-to-many relationship 131
12.1.2 self-referential relationship 133
12.1.3 advanced Many-to-many relationship 134
12.2 Show followers in profile page 136
12.3 Use database junction to query the user's article 138
12.4 showing the user's articles on the home page 141
13th User Reviews 145
13.1 Reviews representation in the database 145
13.2 Submitting and displaying comments 146
13.3 Management Reviews 149
14th Application Programming Interface 153
14.1 Rest Introduction 153
14.1.1 Resources is everything 154
14.1.2 Request Method 154
14.1.3 Request and Response body 155
14.1.4 version 156
14.2 using flask to provide rest Web services 156
14.2.1 Creating an API Blueprint 157
14.2.2 Error Handling 157
14.2.3 using Flask-httpauth Certified users 159
14.2.4 Token-based authentication 161
14.2.5 serialization conversion of resources and JSON 162
14.2.6 Implementing Resource Endpoint 165
14.2.7 Paging Large Resource Collection 167
14.2.8 using Httpie to test Web services 168
Part III success in sight
Chapter 15th Test 173
15.1 Get Code Coverage report 173
15.2 Flask Test Client 176
15.2.1 Test Web Program 176
15.2.2 Testing Web Services 179
15.3 End-to-end testing with selenium 180
15.4 Worth Testing? 184
16th Chapter Performance 185
16.1 Logging slow database queries that affect performance 185
16.2 Analysis Source 187
Chapter 17th Deployment 189
17.1 Deployment Process 189
17.2 Write errors in the production environment to log 190
17.3 Cloud Deployment 191
17.4 Heroku Platform 191
17.4.1 Preparation Procedure 192
17.4.2 Testing with Foreman 196
17.4.3 using Flask-sslify to enable secure HTTP 197
17.4.4 executing the GIT push command deployment 198
17.4.5 Viewing Logs 199
17.4.6 Deploying an Upgrade 199
17.5 Legacy Hosting 200
17.5.1 Server 200
17.5.2 Importing Environment Variables 200
17.5.3 Configuration Log 201
Chapter 18th Other Resources 203
18.1 Using the integrated development environment 203
18.2 Find Flask Extensions 204
18.3 participation in FLASK development 204
About the cover Figure 205
: Network Disk Download
Flaskweb development: Python-based Web application Development Practical PDF