The following is a simple implementation of a REST API with poor coding practices and no software design. Try to improve this code by applying everything you've learned about software design patterns, clean code, and SOLID principles.
-
Download Python from Python Official Website.
-
Install Python and set up the environment variable.
-
Open Git Bash. I recommend using Git Bash for the following steps.
-
Clone this repository or unzip the folder and go to the folder
-
Create a virtual environment using the following command:
python -m venv venv -
Activate the virtual environment with this command:
source venv/bin/activate -
Install Flask by running:
pip install Flask -
Install Flask-RESTful with the following command:
pip install flask_restful -
Download Insomnia from Insomnia Website or Postman
-
Run the Flask app with this command:
python app.py -
Use Insomnia or Postman to make requests to the URL provided by the Python app.
Certainly, here are the improved and corrected steps for your API endpoints:
-
Login: Returns a fake token for authentication.
- Method: POST
- Path: /auth
-
Products:
-
Get Products
{ "method": "GET", "path": "/products", "authToken": "required" } -
Get Product
{ "method": "GET", "path": "/products/productId", "authToken": "required" } -
Get Products by Category
{ "method": "GET", "path": "/products?category=categoryName", "authToken": "required" } -
Create Product
{ "method": "POST", "path": "/products", "authToken": "required", "body": { "name": "nameProduct", "category": "categoryProduct", "price": 9 } }
-
-
Categories
-
Get Categories
{ "method": "GET", "path": "/categories", "authToken": "required" } -
Create Category
{ "method": "POST", "path": "/categories", "authToken": "required", "body": { "name": "nameProduct" } } -
Delete Category
{ "method": "DELETE", "path": "/categories", "authToken": "required", "body": { "name": "nameProduct" } } -
Division trabajo
-
Products: Jorge
-
Favoritos: Jaiber
-
Auth: Isaac
-
Categorias: Adrian
-
Documentacion y entregable: Camilo
-