Item Catalog is an app that provides a list of items within a variety of categories, as well as provide a user registration and authentication system through google login.
- python3.5: Download from https://www.python.org/downloads/
- flask
pip3 install flask
- sqlalchemy
pip3 install sqlalchemy
- oauth2client
pip3 install oauth2client
- sqlalchemy_utils
pip3 install sqlalchemy_utils
- psycopg2-binary
pip3 install psycopg2-binary
- Create the database and objects
python3 models.py
- Insert categories into database
python3 insert_categories.py
- Run the project
python3 views.py
- Go on your web browser to http://localhost:8000. Recommended browser is Chrome.
- If the login button does not show up in http://localhost:8000/login, then make sure to clear your cache.
- Apache
- WSGI
- Amazon Lightsail
- Made an AWS account from Amazon
- Create Ubuntu 16.04 LTS instance
- The public IP is 35.167.198.96
- Update and upgrade the lightsail instance
sudo apt-get updatesudo apt-get upgrade
- Install apache
sudo apt-get install apache2
- Install and enable mod_wsgi
sudo apt-get install libapache2-mod-wsgi-py3sudo a2enmod wsgi
- Install postgresql
sudo apt-get install postgresql
- Create user 'grader' on lightsail
sudo adduser grader
- Give grader sudo powers
- Create the file /etc/sudoers.d/grader with the following text:
# Created by cloud-init v. 17.2 on Sun, 24 Mar 2019 02:34:14 +0000 # User rules for grader grader ALL=(ALL) NOPASSWD:ALL
- Create the file /etc/sudoers.d/grader with the following text:
- On vagrant machine used ssh-keygen to generate a private public key pair and saved it in ~/.ssh/lightsail_grader
ssh-keygen- This will generate 2 files where the .pub is the public key:
- ~/.ssh/lightsail_grader
- ~/.ssh/lightsail_grader.pub
- Install the public key on the lighsail server
- copy the key generated on our vagrant machine (lightsail_grader.pub) to lightsail /home/grader/.ssh/authorized_keys
- Disable root login
- Edit /etc/ssh/sshd_config, changing PermitRootLogin to no
- Force users to ssh for login
- Edit /etc/ssh/sshd_config:
- RSAAuthentication yes
- PubkeyAuthentication yes
- PasswordAuthentication no
- Edit /etc/ssh/sshd_config:
- Change the ssh port from 22 to 2200:
- Add a custom port 2200 in lightsail: https://lightsail.aws.amazon.com/ls/webapp/us-west-2/instances/lz-item-catalog/networking
- Edit the /etc/ssh/sshd_config from Port 22 to Port 2200
- Restart the sshd service:
sudo service sshd restart
- Set up the firewall to only allow ports 2200, 80, 123:
sudo ufw default deny incomingsudo ufw statussudo ufw default deny incomingsudo ufw default allow outgoingsudo ufw allow sshsudo ufw allow 2200/tcpsudo ufw allow wwwsudo ufw allow 123/udpsudo ufw deny 22sudo ufw enable- reboot the amazon lightrail server: https://lightsail.aws.amazon.com/ls/webapp/us-west-2/instances/lz-item-catalog/connect
- Cloned Item_Catalog into /var/www/FlaskApps
- Setting up wsgi
- Create the file /var/www/FlaskApp/flaskapp.wsgi
- flaskapp.wsgi will import from the Item_Catalog __init__.py file
- Create /etc/apache2/sites-available/FlaskApp.conf file to configure which is root directory
- enable the FlaskApp:
sudo a2ensite FlaskApp
- Create the file /var/www/FlaskApp/flaskapp.wsgi
- Setting up postgresl
- Create psql user ubuntu
- Grant permissions to item_catalog to ubuntu
- Created __init__.py file which is the main driver of apache project
- Login to grader using:
ssh grader@35.167.198.96 -p 2200 -i /path/to/the/file/lightsail_grader/
- Homepage displays all current categories along with the latest added items.
- Selecting a specific category shows you all the items available for that category.
- After logging in, a user has the ability to add, update, or delete item info.
- The application provides a JSON endpoint of all categories and items: