This is a sample project for Udacity's "Programming Foundations" course, and the Full Stack Web Dev nano-degree.
In this project, I've created a Catalog app, in a very generic and basic way. The intent is not to have a production ready application, but to demonstrate some of the core concepts of authentication, access control, and CRUD operations on a database.
You'll need to have Python installed on your computer. Python 2.7 is the version this application is developed on.
I suggest using pipenv
to create a python environment and the directions I give will assume you are using this.
Also, this app uses secrets stored in two json files. There are examples of these, file saved with this project, but should be replaced with your own.
The first file, client_secrets.json, requires a Google OAuth API setup. See this Google documentation to get setup and get your "client_secrets.json" file.
The next file is just a custom secrets.json file. The only info stored in it is the secret key passed to the main flask app
instance on first run. You can just remove the .example
from the end of the suplied secrets.json.example
file. If using in production, the value of "SUPER_SECRET_KEY" whould need to be kept secret.
One you have these json files ready, you can run the app.
-
Download and unzip the files in this zip file, or clone with
git clone git@github.com:beaukinstler/fswd-item-catalog.git
-
cd
into the 'fswd-item-catalog' folder. -
If you haven't installed
pip
on your machine, please do so. -
If you haven't installed
pipenv
, typepip install pipenv
-
If you haven't yet created the pipenv, type:
pipenv --python 2.7
-
Then, use the Piplock file to install the dependencies bu running:
pipenv install
NOTE: If you don't want to use pipenv, and you wish to do this manually, read the Pipfile and install the python dependencies listed
-
Now you should be close to ready. By default, this app runs on http://localhost:5000. If you wish to change the port, or have a conflict, change the port at the end of the
main_app.py
file -
Run the app, using this command:
pipenv run python main_app.py
-
Open a web browser and type in http://localhost:5000, and be sure to change 5000 if you customized the port.
IMPORTANT: The first time you visit the /login url, the application will create an "admin" account if one is not found in the database. When it does, it sets the password to password
. You should first log in as admin
and change the password.
When you navigate the /login
page, you'll be asked authenticate, either with Google, or a username and password.
After you setup the admin
user, you can create another user using the "Create User" form.
Another way to create a user is buy authenticating with OAuth, and specifically at this time, Google. The application will create a user in the database if no user matches the email address of your google account.
There are a number of JSON endpoints available. After logging into the application, you can view the list by selecting the JSON menu item.