Python Flask Web Development: From Beginner to Real Projects cover

Python Flask Web Development: From Beginner to Real Projects

No rating yet
Chapters
19
ISBN
9787111630883

Tags

Summary

This is an introductory and hands-on tutorial in Flask for beginners, written by Qian You and published by China Machine Press in 2019. Its 16 chapters fall into three parts. Part 1, Flask Basics (Chapters 1-8), starts with setting up the development environment and then covers configuring Python and a virtual environment, using PyCharm, the basic structure and routing of a Flask application, URL parameters and URL reversing, page navigation and redirection, the Jinja2 template engine (filters, macros, include, template inheritance, loading static files), advanced view techniques, web forms and data interaction, accessing databases with Flask-SQLAlchemy, and the basics of the Memcached caching system and the Bootstrap front-end framework. Part 2, Developing a CMS News System (Chapters 9-14), takes one complete news content management system as its thread, successively completing administrator login in the back end (password hashing, form validation, CAPTCHA, remember me), unlimited-level category classification and CRUD for articles, management of comments and login logs, role-based access control linking permissions, roles, and users, and registration, login, and article display on the public site, finishing with code optimization covering CSRF attacks and defenses and storing CAPTCHAs in Memcached. Part 3, Preparing for and Deploying a Website (Chapters 15-16), introduces slow-query SQL detection and Flask unit testing, and deployment to a production environment with Gunicorn, Nginx, and MySQL. The book includes 116 examples and 28 programming exercises, with source code to be downloaded separately.

Editor's review

很多Flask入门书停在“能跑起一个Hello World”,这本书的野心更大一些:它把知识点串成一条从环境搭建到网站上线的完整链路。全书结构是一大亮点。第1篇用8章把基础打扎实,路由、模板、表单、数据库、缓存、Bootstrap前端框架逐项过一遍,每一项都配可运行的小例子;第2篇直接把这些零件组装成一个CMS新闻系统,登录鉴权、无限级栏目分类、文章增删改查、评论与登录日志、基于角色的权限控制,都是真实后台项目绕不开的模块;第3篇再补上单元测试、慢查询检测,以及Gunicorn加Nginx加MySQL的部署方法,正好是自学者最容易卡住、市面上又最少有人讲清楚的环节。全书配有116个实例和28道编程练习题,讲练结合,适合每天照着敲代码的读者。当然,本书出版于2019年,示例环境偏旧(如基于传统同步式Flask写法),读者需要自行对照当前版本调整依赖。总体而言,它更像一本“跟着做一遍就能独立搭站”的实操手册,性价比不错。

Who it's for

A good fit for

  • 已掌握Python基础语法,想学习用Flask搭建网站的开发者
  • 会写HTML、CSS和jQuery,希望补齐后端能力的前端人员
  • 熟悉Java或PHP、想快速上手Python Web框架的程序员
  • 需要完整项目案例练手的计算机专业高年级学生
  • 希望有一套可照做教材的培训机构讲师与学员

Not a good fit for

  • 完全没有编程基础、不熟悉Python语法的零基础读者
  • 只想了解Flask原理与源码机制、不打算动手做项目的读者
  • 需要最新Flask 3.x与异步、容器化部署方案的一线工程师

Reading tips

  1. 先花一两天配好Python虚拟环境和PyCharm,再动手,不要跳过第1章
  2. 第1篇每章末尾的习题务必动手做一遍,代码敲过才记得住
  3. 第2篇建议用Git分支逐章提交,方便对照书中源码排查问题
  4. 留意书中依赖版本较旧,遇到报错优先查阅官方文档并适当调整版本

About the publisher

China Machine Press China · Founded in 1950

In addition to science and technology and professional publishing, the books in our catalog from China Machine Press also reflect a sustained focus on psychology, computing, management, finance and economics, and social sciences. In psychology, the catalog includes works by C. G. Jung and introductions to analytical psychology, as well as applied topics such as stress and health, and addiction and healing. In computing, it features Structure and Interpretation of Computer Programs (JavaScript Edition). Management and finance titles include Administrative Behavior (4th Edition), The Price of Inequality (Collector's Edition), and This Time Is Different: Eight Centuries of Financial Folly (Commemorative Edition). In the philosophy and history of science, there is The Worldview: The Third Edition. Relevant authors include C. G. Jung, William McGuire, Sonu Shamdasani, and Gabor Maté. Public information is limited; the above summarizes the publisher's profile based solely on the books in our catalog.

Contents

  1. Part 1 Flask Basics
  2. Chapter 1 Setting Up the Development Environment
  3. Chapter 2 Getting Started with Flask
  4. Chapter 3 The Jinja2 Template Engine
  5. Chapter 4 Advanced Flask View Techniques
  6. Chapter 5 Data Interaction in Flask
  7. Chapter 6 Accessing Databases
  8. Chapter 7 The Memcached Caching System
  9. Chapter 8 Basic Use of Bootstrap
  10. Part 2 Developing a CMS News System
  11. Chapter 9 Implementing CMS Back-End Administrator Login
  12. Chapter 10 Implementing Basic Article Module Functions in the CMS Back End
  13. Chapter 11 Implementing Comments, Login Logs, and Other Functions in the CMS Back End
  14. Chapter 12 Implementing Role-Based Access Control
  15. Chapter 13 Implementing Public-Facing CMS Site Functions
  16. Chapter 14 Optimizing CMS System Code
  17. Part 3 Preparing for and Deploying a Website
  18. Chapter 15 Performance Testing and Unit Testing of the CMS System
  19. Chapter 16 Website Deployment

FAQ

这本书适合零基础的人学吗?
不太适合。虽然名为“入门”,但它默认读者已经会Python基础语法,并且了解HTML、CSS和jQuery。如果你连变量、函数、类都不熟,建议先补Python基础再回来看这本书。
书中用的是Flask什么版本,现在还能跑吗?
本书2019年出版,示例基于当时的Flask 1.x与Flask-SQLAlchemy早期版本。核心写法今天仍然可用,但部分依赖的安装命令和配置项有变化,建议按官方文档调整版本,遇到报错先查依赖而不是改代码逻辑。
需要先学Django再来学Flask吗?
不需要。Flask是轻量级框架,学习曲线比Django平缓,本书从环境部署讲起,不需要Django经验。反过来,学过Django的读者入手Flask会更快。
书里的配套源码在哪里下载?
据出版方说明,配套源代码等资料需读者自行下载,可在华章公司网站(hzbook.com)搜索本书,在图书页面找到“资料下载”链接获取。具体链接以出版社页面当前信息为准。
这本书对找工作有帮助吗?
它能帮你走通“从零搭一个CMS网站”的流程,作为简历上的个人项目是不错的练手素材。但求职还建议补充数据库索引与事务、Redis缓存、Linux运维和算法基础,不能只靠一本入门书。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

钱游 Author

Qian You: public information is limited. At present, only one work by this author is known, namely Big Data Development Environment Setup and Development Practice, commonly classified under general computer science. Judging from the title and category, the book addresses the practical side of big data development, focusing on environment configuration and the implementation of development workflows. It is therefore a technical work oriented toward hands-on ability rather than theoretical exposition. Its writing style is likely to be clear and step-by-step, aimed at engineering application and serving readers who need to set up and use big data development environments. Since the author's nationality, dates of birth and death, education, positions, and professional experience have no reliable record, no speculation is made here; this note only briefly describes the subject matter of the work and its likely technical writing orientation for readers' reference.

More by the same author

Top rated in the same category