I'm archiving this project because logging in no longer works. It used to have both Google and Facebook login, but Facebook login broke a long time ago and I removed it. Now Google login is broken as well. I know I could fix the login, but I don't plan on maintaining this project long term since it was originally created as an assignment for Udacity's Full Stack Nanodegree and it was mainly for learning purposes. I'm also removing the link to the live site from the Demo section as I don't plan on leaving it up.
Link Collector is a multi-user bookmarking web app built with Flask, a Python Microframework where users can login with their Google account. Admin users can create categories and collections, and non-admin users can add links and update or delete their own links. Admins can edit or delete any links.
In the app, links are contained in categories, and categories are all part of a more general collection. For instance, you might have a collection called Recipes, and within that collection you have categories like Breakfast, Entrees, and Desserts. You would then add links to breakfast recipes in the Breakfast category, and links to desserts in the Desserts category, etc.
These instructions assume you have Python 2.7 installed and that Python 2 is the version of Python running the files. There may be errors if Python 3 is used.
- Clone, fork, or download this repository.
- Rename the file
secret.py.config
tosecret.py
. - Edit
secret.py
and enter your own secret key of randomly generated characters as the value for the variableSECRET_KEY
. Note:secret.py
is in the.gitignore
- take care to ensure it's named properly and that it doesn't get committed to an online repository.
-
Install PostgreSQL if not already installed.
-
Create a PostgreSQL user ID to use for app.
- To quickly test it out locally, you could create a Postgres superuser role. On Windows, you can create a username with the same name as your login to get it to work easily for development purposes only. See below for how to do this from the psql command prompt which you'd get by entering
psql
in the terminal/command prompt. Note: On a Windows machine, you may need to change to the directory where PostgreSQL is installed (ie.C:\PostgreSQL
) in the command prompt before runningpsql
. Replaceusername
below with desired username:
CREATE ROLE "username" superuser; ALTER ROLE "username" WITH LOGIN;
- To quickly test it out locally, you could create a Postgres superuser role. On Windows, you can create a username with the same name as your login to get it to work easily for development purposes only. See below for how to do this from the psql command prompt which you'd get by entering
-
Create
links
database from psql command prompt
CREATE DATABASE links;
- Type
\q
into the psql command prompt and pressenter
to exitpsql
. - Create tables:
python models.py
- Populate database with initial data:
python add_test_data.py
- Create your own Google Web Application project at console.developers.google.com using
OAuth Client ID
for credentials. - Add these Authorized Redirect URIs (you'd want to change these to appropriate URLs using https for your server if using in production.):
http://localhost:5000/gconnect
http://localhost:5000/login
http://localhost:5000/gdisconnect
https://localhost:5000/oauth2callback
- Download JSON for your web application from Google and name it
client_secrets.json
. - Add
client_secrets.json
to the root of the project directory.
- Create a virtual development environment that uses Python 2. (Using a virtual enviornment is suggested but optional.)
- Command that can be used for creating a virtual environment using Python 2 (This example uses Windows. Replace the path to the Python directory if different on your system)
virtualenv venv --python=c:\python27\python.exe
- If you created a virtual environment, start it.
- Mac/Linux:
source venv/bin/activate
- Windows:
source venv/scripts/activate
- Mac/Linux:
- In the project directory, run:
pip install -r requirements.txt
- When ready to exit the virtual environment, enter
deactivate
.
- If you created a virtual environment for this project, start it:
- Mac/Linux:
source venv/bin/activate
- Windows:
source venv/scripts/activate
- Mac/Linux:
- Run app using Flask's built-in server:
python app.py
- In a web browser, go to
http://localhost:5000
to use the app. - To stop the server when done, press
CTRL-C
. - To exit the virtual environment when done, enter
deactivate
.
When you login to the site with Google, you'll be a regular user and can only add links or edit your own links. After you've logged in to the site successfully, you can update the database to make yourself an admin so that you can add, edit, and delete collections and categories.
- In the terminal/command prompt Type
psql links
to open thelinks
database inpsql
. Note: On a Windows machine, you may need to change to the directory where PostgreSQL is installed (ie.C:\PostgreSQL
) in the command prompt before running the command. - Enter
SELECT * FROM users;
to see what theuser_id
is of the account you want to make an admin. Pressenter
when done. - Enter
UPDATE users SET is_admin = True WHERE user_id = #;
, replacing # with theuser_id
of the user you wish to make an admin. - Type
\q
into thepsql
command prompt and pressenter
to exitpsql
.
Make sure you create database roles (This may be helpful: how to use roles and manage permissions in PostgreSQL on a vps) with appropriate limited privledges and don't use Flask's built in server - see Flask documentation on deploying. You'd also want to take the app out of debug mode - near the bottom of app.py
there's a line that says app.debug = True
and you'd want that to be False
in production. Also, make sure you have added appropriate authorized redirect URIs for your server as discussed above in "Setup Steps for Google Sign-in"
Contributions will not be accepted for the project at this time.
I have not included a license for this project because it adapts some Google Sign-In related code from Udacity's Full Stack Nanodegree that does not have an open source license.