A CRUD WebApp using Flask, SQLAlchemy with Google and Facebook OAuth2 listing various restaurants and their menus and menu items.
Users can view the menu items but only owners of the restaurants can edit/delete menu items and edit/delete restaurants.
Any user can add a new restaurant and add menu items to it.
Live version is hosted here.
-
App uses Flask web framework in python in the backend
-
App uses SQLAlchemy as Object Relational Mapper(ORM) to run SQL from Python.
-
Data is stored in an SQLite database locally for development and uses PostgreSQL when hosted in Heroku.
-
App uses Jinja2 template engine to do server-side rendering.
- Python >= 3.5.2
- See requirements.txt for python package requirements.
- A developer account at Google for Google OAuth2 Login Credentials.
- A developer account at Facebook for Facebook OAuth2 Login Credentials.
Assuming that Python >= 3.5.2 (preferably 3.6.8) is installed (a virtualenv is recommended) -
- Install the python packages required to run the application using:
(py3)$ pip install -r requirements.txt -U
- Create the database tables using
(py3)$ python db_models.py
- Populate the databse with initial set of data using:
(py3)$ python db_util.py
-
Register and create client credentials with Google and Facebook (guides to create the same are available in their respective homepages and also on many other sites.)
-
Put the Google and Facebook client credential secrets in
gAuth.json
andfbAuth.json
files respectively inside oauth_data. -
Run the server using:
(py3)$ python server.py
- Application can be accessed at http://localhost:5000 or http://localhost:5000/restaurants
-
/api/v1/restaurants
-GET
- Will get the name and rid of all the restaurants registered in the app. -
/api/v1/restaurants/1
-GET
- Will get the details of restaurant with rid=1. -
/api/v1/restaurants/1/menu
-GET
- Will get the menu for the restaurant with rid=1. -
/api/v1/restaurants/1/menu/1
-GET
- Will get the menu item details with mid=1 from restaurant with rid=1. -
/api/v1/get_owner_for_restaurant?rid=1
-GET
- Will get the owner of the restaurant with rid=1. -
/api/v1/get_restaurants_for_user?user_id=1
-GET
- Will get all the restaurants owned by user with user_id=1.
Run the REST API calls using the API URIs' from above http://localhost:5000/api/v1....
.