Take full creative control of your web applications with Flask, the Python-based microframework. With this hands-on book, you’ll learn Flask from the ground up by developing a complete social blogging application step-by-step. Author Miguel Grinberg walks you through the framework’s core functionality, and shows you how to extend applications with advanced web techniques such as database migration and web service communication. Rather than impose development guidelines as other frameworks do, Flask leaves the business of extensions up to you. If you have Python experience, this book shows you how to take advantage of that creative freedom.
- Learn Flask’s basic application structure and write an example app
- Work with must-have components—templates, databases, web forms, and email support
- Use packages and modules to structure a large application that scales
- Implement user authentication, roles, and profiles
- Build a blogging feature by reusing templates, paginating item lists, and working with rich text
- Use a Flask-based Restful Api to expose app functionality to smartphones, tablets, and other third-party clients
- Learn how to run unit tests and enhance application performance
- Explore options for deploying your web app to a production server
About the Author
Miguel Grinberg has over 25 years of experience as a software engineer. In his current position at Rackspace he spends most of his time contributing to open source projects in the OpenStack ecosystem. He blogs at http://blog.miguelgrinberg.com about a variety of topics including web development, robotics, photography, and the occasional movie review. Miguel lives in Portland, Oregon with his wife, four kids, two dogs, and a cat.
Most helpful customer reviews
30 of 31 people found the following review helpful.
Best reference on Flask I've seen
As a newbie to Flask, I was stuggling to find any complete tutorials that would get me from beginner all the way up to the point where I could develop entire apps on my own. I came across several excellent posts on Flask on Miguel's blog, and then got the book to fill in the gaps.
Miguel does a great job of setting up the environment right from the start (explaining virtualenv and project structure, things often overlooked in the community).
- Using the single example throughout the book is cumbersome. I was truly hoping that you'd switch to a new example in Chapter 7 when we got to Large Application Structure. It's not that the example isn't great, it's just that when you're reading the book over multiple sessions, you tend to forget some of the things covered earlier in the book -- and then a cycle of uncertainty continues to play in the back of your mind .. and eventually reaches a point where you throw your hands in the air, and start the book over. I did that 3 times before the book was finally done. Perhaps using multiple smaller examples might make it easier to grasp.
The book is great, and I've already added it as recommended reading to any developer that joins our company.
15 of 15 people found the following review helpful.
Great tutorial with very clear explanations
I've been using Python for a long time, but hadn't worked with Flask before. I first encountered Miguel's online blog postings: "The Flask Mega-Tutorial" to be very useful and well written. They lead me to this book.
The book covers everything from how to set up Flask in a virtualenv through development, testing and deployment. He fully explains his specific project organization style with the reasoning as to why he made those choices. Again, these items are rarely covered in books and often haphazardly done by naive developers.
Along the way, through Part 1 "Introduction to Flask" he covers the capabilities with examples. Common Flask extensions and useful ancillary packages are well described, again with examples.
Part 2 goes deeper into a larger project, and provides examples and rationalizations for his choices along the way. There are all sorts of great tidbits in there that apply to nearly any project, so don't be put off by what appears to be a highly specific example project.
I think in summary the book has two overriding values to me. First, he covers a lot of ground with examples. After reading, you will have a solid understanding of how to use Flask, and a great reference to flip back through. Second he explains the rationale behind his choices. Anyone can find the documentation online for Flask and the extensions, but understanding what is appropriate and how to use those parts is where this book really helps.
1 of 1 people found the following review helpful.
See all 56 customer reviews...
A definitive guide to learning Flask
By Timothy H. Johnson
The author instructs the building of, in seamlessly connected increments, a social media website. The programmer progresses from the most basic application through the stages of development to full deployment. As has been pointed out, this is just one project. That should not be taken as a criticism. M. Grinberg employs a tried and true methodology. It is incumbent upon the student programmer to do ancillary and peripheral research as one progresses. To so otherwise is to sell oneself short.
As an example: At the Large Application stage, this reviewer took another short, paint-by-numbers, online tutorial just in constructing the file structure of a project. This gave me another view. Additionally, I was not afraid to break things. I cloned the project as another directory and did my experimentation along that folder path. Also, I made use of an sqlite plugin so that I could get a graphical representation of the database structure.
I used a full-blown IDE - so to speak. Emacs with elpy-mode and jinja2-mode plugins. The completion facilities gave insights into the resources and possibilites of the Python Classes. Emacs' robust help system (which extends as the programmer extends emacs functionality though elisp) contributed to that end.
Although the author recommends this book to those who already know python (this reviewer has 20 years of CGI programming, 13 in Python) I believe that someone with extensive programming experience in languages other than python could make constructive use of the book as he/she learned python.
I found no logical or informational gaps between the indivual stages (chapters and subchapters). The author is very approachable and quick to answer questions.