Item Catalog Application is the second project of Udacity Full Stack Web Development Nano Degree Program.
The goal of this application or project is to deploy skills of full stack web development such as RESTFul web application that uses python Flask framework with Oauth authentication. CRUD implementaion to provide support of create, view, update and delete. This application works on local environment.
This application runs on local environment. All required software to run this application is already made available in Vagrantfile provided by Udacity. Hence separately no installation is required. Application:
A. Download(Optional):
B. Installation(If not installed):
- Git
- Virtual Box
- Vagrant
C. Run
- Open command prompt or gitbash terminal
- Create new directory or you can use existing one. For creating directory use mkdir 'DirectoryName' on gitbash terminal/cmd.
- Goto the directory where you want to keep your files and paste downloaded Vagrantfile inside the folder.
- Open VirtualBox
- 'vagrant up' on gitbash/cmd in that folder.
- 'vagrant ssh' on gitbash/cmd once step 5th successfully completed.
- Run 'cd /vagrant' on gitbash/cmd to goto shared directory between host and guest machine.
- clone repository in the shared directory or you can create one and clone inside the folder.
- After completing step 8th, on vagrant goto that folder where repository cloned and run 'python3 database_setup.py'
- To populate database run 'python3 lotsofmenus.py'
- Now run 'python3 application.py', it will start the server.
- Now open browser and type 'https://localhost:5000/' in URL bar to see homepage.
- 'https://localhost:5000/' or 'https://localhost:5000/restaurant/' to view the homepage.
- 'https://localhost:5000/restaurant/new/' to add new restaurant in database.(Required login)
- 'https://localhost:5000/restaurant/int:restaurant_id/edit/' to edit restaurant name(Required login and permission)
- 'https://localhost:5000/restaurant/int:restaurant_id/delete/' to delete restaurant from database.(Required login and permission)
- 'https://localhost:5000/restaurant/int:restaurant_id/menu/' or 'https://localhost:5000/restaurant/int:restaurant_id/' to view all the items available in the restaurant.
- 'https://localhost:5000/restaurant/int:restaurant_id/menu/new/' to add menu item for a restaurant.(Required login)
- 'https://localhost:5000/restaurant/int:restaurant_id/menu/int:menu_id/edit'to edit menu item of a restaurant.(Required login and permission)
- 'https://localhost:5000/restaurant/int:restaurant_id/menu/int:menu_id/delete' to delete item from menu of a restaurant.(Required login and permission)
- 'https://localhost:5000/login/' to login into account.
This application also has json endpoints which can be used access the information from database for development and testing purpose. All endpoints are listed below:
''' { "restaurants": [ { "id": 1, "name": "Urban Burger" } ] } ''' some thing like this one will appear.
- 'https://localhost:5000/restaurant/int:restaurant_id/menu/JSON'
''' { "MenuItems": [ { "course": "Appetizer", "description": "asd", "id": 49, "name": "Gourab", "price": "12" } ] } '''
- 'https://localhost:5000/restaurant/int:restaurant_id/menu/int:menu_id/JSON
''' { "Menu_Item": { "course": "Entree", "description": "Juicy grilled veggie patty with tomato mayo and lettuce", "id": 1, "name": "Veggie Burger", "price": "$7.50" } } '''
A. If shared folder is not visiable, run vagrant reload on gitbash terminal/cmd
B. If packages or modules are not available then open vagrantfile and change/ paste code below to get the python3 compatiable modules and packages.
- sudo apt-get -qqy install python3 python3-pip
- sudo pip3 install --upgrade pip
- sudo pip3 install flask packaging oauth2client redis passlib flask-httpauth
- sudo pip3 install sqlalchemy flask-sqlalchemy psycopg2-binary bleach requests
C. If python3 project.py gives error that might be for dos and unix format difference. To over come install
- run sudo apt-get install dos2unix on gitbash terminal/cmd
- run dos2unix application.py on gitbash terminal/cmd
D. Unreachable issue may be caused due to ignoring 'https://'. 'https://' must be included as Flask app run with ssl_context.
Facebook recently restrict usage of its applications and apis through http connection. Now Facebook only allows 'https' connections. To usage or navigate all the paths 'https://' should be included at begining of the url. To create custom certificate and key run
- sudo pip install pyopenssl
- sudo pip install Werkzeug --upgrade
- openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
**Internet connectivity is required to login with facebook or google **