Skip to content

About

A RESTful API developed during the SENAI "Artificial Intelligence Applied to Programming – ChatGPT" course using Python and Flask to perform basic CRUD operations for product management.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🛒 Product API with Flask

A simple REST API built with Python and Flask as part of a web development course.

This project demonstrates the basic CRUD (Create, Read, Update, Delete) operations using an in-memory list of products.

🚀 Technologies

  • Python 3
  • Flask
  • Flask-CORS

📦 Installation

1. Clone the repository

git clone https://github.com/maezono00/api-produtos.git

2. Navigate to the project folder

cd api-produtos

3. Install the dependencies

pip install flask flask-cors

Or, if you have a requirements.txt file:

pip install -r requirements.txt

▶️ Running the application

Start the server by running:

python app.py

The API will be available at:

http://localhost:8000

📚 API Endpoints

Get all products

GET /

Returns the list of all products.

Response

[
  {
    "id": 1,
    "nome": "Notebook Gamer",
    "preco": 4000
  },
  {
    "id": 2,
    "nome": "Gaming Chair",
    "preco": 300
  }
]

Create a product

POST /criar

Request Body

{
  "id": 4,
  "nome": "Gaming Mouse",
  "preco": 150
}

Response

{
  "id": 4,
  "nome": "Gaming Mouse",
  "preco": 150
}

Status:

201 Created

Update a product price

PUT /atualizar/{id}

Request Body

{
  "preco": 4500
}

Response

{
  "preco": 4500
}

If the product ID is not found:

{
  "mensagem": "ID not found!"
}

Delete a product

DELETE /apagar/{id}

Response

{
  "mensagem": "Product removed!"
}

If the product ID is not found:

{
  "mensagem": "ID not found!"
}

📂 Project Structure

.
├── app.py
└── README.md

📝 Notes

  • The application uses an in-memory data structure, so no database is required.
  • All data will be reset whenever the application is restarted.
  • This project was created for educational purposes to practice building REST APIs with Flask.

👨‍💻 Author

Developed as part of a SENAI course to learn the fundamentals of REST API development using Python.

About

A RESTful API developed during the SENAI "Artificial Intelligence Applied to Programming – ChatGPT" course using Python and Flask to perform basic CRUD operations for product management.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages