Book Image

Flask By Example

By : Gareth Dwyer
Book Image

Flask By Example

By: Gareth Dwyer

Overview of this book

This book will take you on a journey from learning about web development using Flask to building fully functional web applications. In the first major project, we develop a dynamic Headlines application that displays the latest news headlines along with up-to-date currency and weather information. In project two, we build a Crime Map application that is backed by a MySQL database, allowing users to submit information on and the location of crimes in order to plot danger zones and other crime trends within an area. In the final project, we combine Flask with more modern technologies, such as Twitter's Bootstrap and the NoSQL database MongoDB, to create a Waiter Caller application that allows restaurant patrons to easily call a waiter to their table. This pragmatic tutorial will keep you engaged as you learn the crux of Flask by working on challenging real-world applications.
Table of Contents (20 chapters)
Flask By Example
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Index

Running a database application locally


In order to develop and debug locally, we need to be able to run the application. However, at the moment, this is not possible as MySQL is only installed on our VPS. There are three main options to develop our database application locally:

  • Connecting to the database on our VPS even when running Flask on our local machine

  • Installing MySQL on our local machine

  • Creating a "mock" of our database in memory using Python

While any could work, we'll go with the third option. Connecting to our production database would cause us to be affected by latency if we develop in a location far from our VPS, and this would also mean that we'd run test code against our production database, which is never a good idea. The second option would limit the portability of our development environment, increase setup time if we switch to a new development environment, and in the worst case scenario, use up a significant amount of local resources.

Creating a mock of our database

If you...