Create a postgresql database
CREATE DATABASE simple_crud_flask;
CREATE USER simple_flask WITH PASSWORD 'pass_simple_flask';
GRANT ALL PRIVILEGES ON DATABASE simple_crud_flask TO simple_flask;
-
Install pipenv
-
Install pipenv packages
pipenv install
-
Run flask application
There are two ways to run the web application with pipenv
-
Enabling first pipenv
pipenv shell
Flask run
-
Directly running with pipenv
pipenv run Flask run
-
-
Create a product
curl -X POST \ http://127.0.0.1:5000/products \ -H 'Content-Type: application/json' \ -d '{ "title": "Jamón serrano", "productDescription": "Jamón serrano Fud 290g", "productBrand": "Fud", "price": 48.5 }'
-
Get products list
curl -X GET \ http://127.0.0.1:5000/products \ -H 'Content-Type: application/json'
-
Retrieve a product
curl -X GET \ http://127.0.0.1:5000/products/1 \ -H 'Content-Type: application/json'
-
Update a product
curl -X PUT \ http://127.0.0.1:5000/products/1 \ -H 'Content-Type: application/json' \ -d '{ "price": 53 }'
-
Delete a product
curl -X DELETE \ http://127.0.0.1:5000/products/1 \ -H 'Content-Type: application/json'