Book Image

Mastering Flask

By : Jack Stouffer
Book Image

Mastering Flask

By: Jack Stouffer

Overview of this book

Starting from a simple Flask app, this book will walk through advanced topics while providing practical examples of the lessons learned. After building a simple Flask app, a proper app structure is demonstrated by transforming the app to use a Model-View-Controller (MVC) architecture. With a scalable structure in hand, the next chapters use Flask extensions to provide extra functionality to the app, including user login and registration, NoSQL querying, a REST API, an admin interface, and more. Next, you’ll discover how to use unit testing to take the guesswork away from making sure the code is performing as it should. The book closes with a discussion of the different platforms that are available to deploy a Flask app on, the pros and cons of each one, and how to deploy on each one.
Table of Contents (20 chapters)
Mastering Flask
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Deploying on Heroku


Heroku is the first of the Platform as a Service (PaaS) providers that this chapter will cover. PaaS is a service given to web developers that allows them to host their websites on a platform that is controlled and maintained by someone else. At the cost of freedom, you gain assurances that your website will automatically scale with the number of users your site has with no extra work on your part. Using PaaS also tends to be more expensive than running your own servers.

Heroku is PaaS that aims to be easy to use for web developers by hooking into already existing tools and not requiring any large changes in the app. Heroku works by reading the file named Procfile, which contains commands that your Heroku dyno basically a virtual machine sitting on a server, will run. Before we begin, you will need a Heroku account. If you wish to just experiment, there is a free account available.

In a new file named Procfile in the root of the directory, add the following:

web: uwsgi uwsgi...