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

Using the MongoDB shell


Similarly to what we discussed with MySQL, MongoDB comes with a simple shell. This is ideal to run quick, one-off commands and get used to the syntax. Let's run through the basic CRUD operations to get familiar with how MongoDB works.

As in our previous project, once we introduce MongoDB, we'll move to using it only through Python code; however, to start out, we'll write commands directly in the shell. This means there will be some slight differences in syntax, but as nearly everything is JSON based, these differences shouldn't be a problem.

Starting the MongoDB shell

To start the MongoDB shell, run the following command on your VPS:

mongo

This will start the interactive MongoDB shell as in the following image, which you can exit at any time by pressing Ctrl + C or by typing exit into the shell and pressing Enter.

Running commands in the MongoDB shell

As with MySQL, the top-level concept in MongoDB is a database. By default, this will connect to a database named test....