Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building Web Applications with Flask
Building Web Applications with Flask

Building Web Applications with Flask: Use Python and Flask to build amazing web applications, just the way you want them!

By Italo M Campelo Maia , Jack Stouffer , Gareth Dwyer , Italo Maia
$29.99 $20.98
Book Jun 2015 160 pages 1st Edition
eBook
$29.99 $20.98
Print
$38.99
Subscription
$15.99 Monthly
eBook
$29.99 $20.98
Print
$38.99
Subscription
$15.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Jun 26, 2015
Length 160 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781784396152
Category :
Table of content icon View table of contents Preview book icon Preview Book

Building Web Applications with Flask

Chapter 1. Flask in a Flask, I Mean, Book

What is Flask? It's a question that humanity has been pondering for millennia... well, actually, since 2010, when Armin Ronacher first committed to the project. Flask is a Web framework and is quite different from what most people are used to working with. It is less presumptuous about how your application should look or what you should use to make it available. The BSD licensed package has all this!

An introduction to Flask and its features


The Flask framework is actually a glue, a very nice one, that sticks together the amazing Werkzeug and Jinja2 frameworks, responsible for answering requests and presenting the output (HTML, maybe). In the MVC architecture, also known as Model-View-Controller, Flask covers C and V. But where is M? Flask does not provide you with an integrated model layer out-of-the-box as that is not actually needed for a web application. If you do need to work with a database, just pick your database solution from the many available and create your own model layer, which is not hard, and be happy! The concept of a micro-framework, with good intentions and made just for Flask, is all about giving you the the smallest (but also the most useful) feature set you need, and one that won't get in the way.

Just what are the features that must be in the framework?

  • A development server and debugger (sanity-friendly)

  • Unicode support (Latin language-friendly)

  • WSGI compliance (uWsgi-friendly)

  • A unit-test client client (code with quality)

  • URL routing (it brings tears to my eyes, it's so beautiful!)

  • Request dispatching

  • Secure cookies

  • Sessions

  • Jinja2 templates (tags, filters, macros, and more)

With that much, you can handle Ajax requests, browser requests, and user sessions between requests; route HTTP requests to your controllers; evaluate form data; respond to HTML and JSON; and so on.

That is nice, but is Flask not an MVC framework? Well, that's arguable. If a web framework does not implement an MVC antipattern, such as handling requests in the view or mixing models and controllers, it could potentially facilitate an MVC, which, in my opinion, is as good as it gets because it does not enforce your application structure.

Note

Flask is not an MVC framework as it does not implement the model layer, although it does not restrict you in any way if you wish to create your own.

If you need a simple, single-file web application that receives a form and gives back an answer, HTML or not, Flask will help you with that, easily. If you need a multilayer, high-depth modularized Facebook clone, Flask can also be there for you.

So, what did we learn so far?

  • Flask was born in 2010

  • Flask is a minimalistic web framework based on Jinja2 and Werkzeug

  • Flask does not enforce a specific project architecture

Note

Refer to Flask license details at http://flask.pocoo.org/docs/0.10/license/.

Right now, you might be wondering which of your neat project ideas could be done with Flask. That's the spirit! What about thinking together on this one?

Flask does not come with bundled functionality in terms of database integration, a forms library, administration interface, or migration tools. You can have these through extensions, which will be discussed soon enough, but they are all external to Flask. If you need these extensions right at the beginning of your project and you don't want to set it up (or can't spare the time to), you might do better with a full-fledged MVC all-in one, low-cohesive, and high-coupling framework such as Django.

Now, imagine you need to build a website with a single form, such as a http://cashcash.cc/ clone, which receives a form and returns the current currency trade values; Flask could help conclude your project really fast.

Let's think further. What if you need a specific set of libraries to work together in your project and you don't want the web framework getting in the way; that's another very good scenario for Flask as it gives you the bare minimum and lets you put together everything else you may need. Some frameworks have such a high level of coupling (read dependency) on their own components that you may have a serious problem if you want to use a specific alternative.

For example, you may want to use a NoSQL database in your project; however, if you do so, some components of your project may stop working (for example: an administrative component).

Basically, if you have the time to spare, if you're doing something simple, if you want to implement your own architecture solution, or if you need granular control of the components used in your project, Flask is the web framework for you.

Summary


Now, let's talk about awesomeness, your awesomeness after reading this book—you will be capable of handling HTTP and Ajax requests; creating fully featured web applications with database integration (SQL and NoSQL) and REST services; using Flask extensions (forms, caching, logging, debugging, auth, permissions, and so on); and modularizing and unit- and feature-testing your applications.

I hope you enjoy this book and build great things with what you learn here

Left arrow icon Right arrow icon

Key benefits

What you will learn

Create single page applications with Flask Use macros, filters, tags, and control structures to render rich responses to user requests Receive forms securely through formbased classes and WTForms Utilize NoSQL or SQL databases to store user data seamlessly Generate simple, yet powerful, REST services from your data models Learn how to perform testdriven and behaviordriven developments in your Flask projects Use Flask components to create maintainable nonflat projects Harvest the power of extensions to build robust authorization and permission policies

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Jun 26, 2015
Length 160 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781784396152
Category :

Table of Contents

17 Chapters
Building Web Applications with Flask Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the Author Chevron down icon Chevron up icon
About the Reviewers Chevron down icon Chevron up icon
www.PacktPub.com Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
Flask in a Flask, I Mean, Book Chevron down icon Chevron up icon
First App, How Hard Could it Be? Chevron down icon Chevron up icon
Man, Do I Like Templates! Chevron down icon Chevron up icon
Please Fill in This Form, Madam Chevron down icon Chevron up icon
Where Do You Store Your Stuff? Chevron down icon Chevron up icon
But I Wanna REST Mom, Now! Chevron down icon Chevron up icon
If Ain't Tested, It Ain't Game, Bro! Chevron down icon Chevron up icon
Tips and Tricks or Flask Wizardry 101 Chevron down icon Chevron up icon
Extensions, How I Love Thee Chevron down icon Chevron up icon
What Now? Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.