Skip to content

amirn003/flask-crud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

CRUD with Flask

This project provides a simple CRUD API for managing products using Flask.

Installation

  1. Install the required packages:

    python3 -m pip install flask flask_cors

Running the Application

  1. Run the app:

    python3 products.py

API Endpoints

Get All Products

  • URL: /products

  • Method: GET

  • Description: Returns a list of all products.

    curl http://localhost:5000/products

Get a Product by ID

  • URL: /products/{id}

  • Method: GET

  • Description: Returns a product based on the product ID.

    curl http://localhost:5000/products/144

Add a Product

  • URL: /products

  • Method: POST

  • Description: Adds a new product to the list.

    curl -X POST -H "Content-Type: application/json" \
    -d '{"id": 145, "name": "Pen", "price": 2.5}' \
    http://localhost:5000/products

Update a Product

  • URL: /products/{id}

  • Method: PUT

  • Description: Updates an existing product based on the product ID.

    curl -X PUT -H "Content-Type: application/json" \
    -d '{"name": "Updated Pen", "price": 3.0}' \
    http://localhost:5000/products/145

Delete a Product

  • URL: /products/{id}

  • Method: DELETE

  • Description: Deletes a product based on the product ID.

    curl -X DELETE http://localhost:5000/products/145

Testing

You can test the API using the provided curl commands or any API testing tool like Postman.

Swagger Documentation

The API is documented using Swagger. You can find the Swagger JSON file in the static directory.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages