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

Testing our application in production


Our application should now be fully functional once we add the preceding code! As with the database section of our Crime Map application, this bit is the most delicate as we haven't been able to test the DBHelper code locally, and we'll have to debug it directly on the VPS. However, we're confident, from our MockDBHelper class, that all our application logic is working, and if the new database code holds up, everything else should go as expected. Let's push our code to the server and test it out.

Locally, run the following commands in your waitercaller directory:

git add .
git commit -m "DBHelper code"
git push origin master

On your VPS, change to the WaiterCaller directory, pull the new code, and restart Apache, as follows:

cd /var/www/waitercaller
git pull origin master

Now, create the production config file using nano by running the following command:

nano config.py

Type the following into the new config.py file, substituting the IP address in base_url...