This project, Noah's Ark, was developed to pass the second project in Udacity's Full Stack Nanodegree program (July '19'). The application tracks which animals are on board of the ark. It categorizes animals in a variety of classes and families. Classes and Families can be added by users who have registered & loged in via an OAUTH authentication system. Authenticated users can further edit and delete items they have created.
This project makes use of a Linux-based virtual machine (VM), a SQLite database and Python.
VirtualBox is software that runs virtual machines. Download it from virtualbox.org. Install the platform package for Mac. No need to download the extension pack or the SDK.
Vagrant is the software that configures the VM and lets you share files between your host computer and the VM's filesystem. Download it from vagrantup.com. This project requires a specific vagrant file (udacity fullstack vm
) provided by Udacity for the nanodegree. Please download it [here] (https://github.com/udacity/fullstack-nanodegree-vm).
The main app, project.py, is written in Python and makes use of SQLAlchemy and a SQLite database (animal_catalog.db) to store information on animal classes (table: AnimalClasses), families (table: ClassFamilies) and the users who created them (table: Users). Flask is used to render interactive HTML templates that GET and POST information from/to the database. The authentication is done via exchanging tokens with Google OAUTH2's service. The login page performs the authentication via AJAX scripts.
In order to run the python script, follow these steps:
- Download and extract the .zip file into your /vagrant directory
- Bring the virtual machine online (with
vagrant up
). Then log into it withvagrant ssh
. Your shell prompt should start with the word "vagrant" displaying that you're logged into your Linux VM. - Use your shell to
cd
into thevagrant
directory
- To create a test entry, run the file:
python prepopulateDB.py
- Run the main file to start hosting the web application on your localhost
python project.py
- You can test out the API functionality by adding a
/JSON
to URLs of the overview of all classes, the overview of all families in a class and individual family members. For example,/classes/1/family/JSON
will show the name, id and description of the animal class with theid = 1
in JSON format.
Use your favorite browser to connect to the application at http://localhost:8000/classes. After you go to the page Login and authenticate via Google OAUTH, you can add, edit and delete your animal classes and families.
Once you're logged in, you will see a Logout link in the sidebar navigation. Click on the link to end your session. In the shell, you can end the web server and exit vagrant by pressing CTRL+C twice.