Flask from Beginner to Advanced: Python Web Engineering Practices
A newer and better Flask book available in Chinese.- The first Flask book in China, it covering the complete Flask Web development learning path and including the complete Flask Web application development process.
- The book based on Flask 3.0.x. Besides, all the Python packages, CSS frameworks and JavaScript libraries use the latest version.
- In addition to basic knowledge, it also covered Web API, full-text search, third-party login, AJAX, source code analysis and other practical contents.
- It comes with 8 example application, 2 real-world projects. See more information below.
- All chapters of the book have been carefully designed and arranged to meet the needs of different levels of readers, and to allow readers to master the basics and skills of Flask development step by step.
Companion Applications
-
Flask Examples
A collection of simple Flask applications that demonstrates the basic usages of Flask, including http, template, form, database, email, cache and assets profiling.
Hello, Flask!
Recommendations
Great resources make great developers, and it’s wonderful to see Flask supported by such high-quality education materials.
—— Armin Ronacher (Author of Flask, VP of Platform at Sentry)
As a passionate Python software engineer and an evangelist who enjoys helping others and giving back to the community, Grey’s relentless pursuit of technical accuracy and an excellent reading experience are fully reflected in this new book. I believe every reader will feel his sincerity between the lines.
—— Jun Guan (Translator of The DevOps Handbook (2nd Edition), DevOps Architect at Dell China R&D Excellence Group)
This book is rich in content and is recommended for those who want to learn Flask systematically. Don’t miss the small knowledge points in the book!
—— Hsiaoming Yang (Founder of Typlog, Author of Authlib)
About the Author
Grey Li, maintainer of Flask & APIFlask, member of the Pallets Team, creator of the HelloFlask community and the CodeKitchen community, and Microsoft Most Valuable Professional (MVP) in Python. He currently works at Dell China R&D Excellence Group as a Principal Software Engineer.
He is passionate about open-source software development and promotion, and has contributed a large amount of code to open-source projects such as Flask. He has spoken at major tech conferences including PyCon China, PyCon US, COSCUP, COSCon, and CommunityOverCode. You can find his open-source projects on GitHub. To learn more about him, visit his personal website.
If you want to learn about his latest works or updates, you’re welcome to follow his Twitter, or join his mailing list.
Intended Readers
The intended audience of this book includes:
- Programming enthusiasts who understand basic Python syntax and want to build websites on their own
- Backend engineers, DevOps engineers, and web scraping engineers who are familiar with Python and want to engage in Python web development
- Python engineers who want to switch from other Python web frameworks such as Django to Flask
This book does not cover the fundamentals of Python, so readers should already have a basic understanding of Python syntax. In addition, web development inevitably involves some knowledge of HTML, CSS, and JavaScript. If you’re not familiar with these, you can study the Web Development Tutorials provided by MDN for a quick introduction.
Table of Contents
This book is divided into three parts, with a total of 14 chapters.
Basics
- Chapter 1 Introduction to Flask
Setting up the development environment, writing a minimal Flask program, running it, and understanding the basics of Flask. - Chapter 2 Flask and HTTP
Introduction to the interaction between Flask and HTTP, as well as relevant Flask features. - Chapter 3 Templates
Usage and techniques of Jinja2 templates; using and integrating the CSS framework Bootstrap. - Chapter 4 Forms
Creating web forms and validating form data. - Chapter 5 Database
Using SQLAlchemy for CRUD operations on databases within a Flask program, establishing and operating various database relationship models. - Chapter 6 Automated Testing
Introduction to automated testing for Flask programs, including test writing, calculating test coverage, code quality checks, type annotation checks, etc.
Practical Applications
- Chapter 7 Advanced Flask Practices
Introduction to advanced techniques in Flask web development, including file uploads, email, AJAX, rich text editors, etc. - Chapter 8 Project Organization
Introduction to organization methods and techniques for Flask projects, including factory functions, blueprints, and configuration management. - Chapter 9 Personal Blog
Introduction to CRUD operations, user authentication, article comments, management backend, etc., through the personal blog program Greybook. - Chapter 10 Image Social Network
Introduction to user registration and authentication, user permission management, image upload and processing, user avatars, complex database relationships, complex database queries, full-text search, etc., through the image social program Moments.
Advanced Topics
- Chapter 11 Web API Development
Introduction to Web API design and using APIFlask for Web API development. - Chapter 12 Performance Analysis and Optimization
Introduction to main measures for optimizing the performance of Flask programs, including performance analysis of functions and database queries, cache usage, and static file optimization. - Chapter 13 Deployment
Introduction to preparations before deploying Flask programs, as well as traditional deployment (deploying to Linux servers) and container deployment. - Chapter 14 Analysis of Flask's Working Principles and Mechanisms
Introduction to some design concepts of Flask, including the underlying WSGI implementations, and source code analysis of major functionalities.