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

Setting up Celery and RabbitMQ


To install Celery with pip, run the following:

$ pip install Celery

We will also need a Flask extension to help handle initializing Celery:

$ pip install Flask-Celery-Helper

The Flask documentation states that Flask extensions for Celery are unnecessary. However, getting the Celery server to work with Flask's application context when your app is organized with an application factory is significant. So, we will use Flask-Celery-Helper to do the heavy lifting.

Next, RabbitMQ needs to be installed. RabbitMQ is not written in Python; therefore, installation instructions will be different for every OS. Thankfully, RabbitMQ maintains a detailed list of instructions for each OS at https://www.rabbitmq.com/download.html.

After RabbitMQ is installed, go to a terminal window and run the following:

$ rabbitmq-server

This will start a RabbitMQ server with a user of guest and a password of guest. By default, RabbitMQ only accepts connections on localhost, so this setup is...