Create a RESTful API to implement CRUD operations on data sent by http request.
I chose to use this framework since it is scalable and functional. The http requests are routed by Flask and SQLAlchemy interacts with the PSQL database to control the CRUD operations. The JSON returned is serialized data from the PSQL db.
IP address = localhost:5000
URL = http://localhost:5000/v1/
--Python--
- Python 2.7 (apt-get install python2.7) **NOTE Python 2.7 libraries will be depreciated on 1/2020
- Flask (pip install flask)
- SQL Alchemy (pip install sqlalchemy)
- Requests (pip install requests)
- Psycopg2 (pip install psycopg2) + (pip install psycopg2-binary)
--Database--
Postgresql (sudo apt-get install postgresql-12)
SCRIPTS to run:
- CREATE USER products_user WITH PASSWORD 'U$er';
- CREATE TABLE products (id serial, Name varchar(250), Price varchar(250));
- GRANT ALL PRIVILEGES ON products TO products_user;
- GRANT USAGE, SELECT ON SEQUENCE products_id_seq TO products_user;
- Download and install software (Outlined above)
- Start PostgreSQL server (pg_ctlcluster 12 main start)
- Run PSQL scripts as POSTGRES user (-u postgres -i)
- Clone repository https://github.com/NSPurington/API_Test_Handler (git clone ....)
- Run add_products.py (python add_products.py)
- Run init.py (python init.py) (Include 2 underscores before and after 'init'. Escaped out in GitHub formatting)
- Send API calls to http://localhost:5000/v1/ (using Postman or Curl)
This app is programmed with Python back-end code, and uses Flask, SQL Alchemy, and Psycopg2 to interact with non-Python sources.
Flask documentation - Online SQL Alchemy documentation - Online Postgresql official documentation - Online Psycopg2 official documentation - Online
Author - Nick Purington - Developer