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.
- Python 3
- Flask
- Flask-CORS
git clone https://github.com/maezono00/api-produtos.gitcd api-produtospip install flask flask-corsOr, if you have a requirements.txt file:
pip install -r requirements.txtStart the server by running:
python app.pyThe API will be available at:
http://localhost:8000
GET /
Returns the list of all products.
[
{
"id": 1,
"nome": "Notebook Gamer",
"preco": 4000
},
{
"id": 2,
"nome": "Gaming Chair",
"preco": 300
}
]POST /criar
{
"id": 4,
"nome": "Gaming Mouse",
"preco": 150
}{
"id": 4,
"nome": "Gaming Mouse",
"preco": 150
}Status:
201 Created
PUT /atualizar/{id}
{
"preco": 4500
}{
"preco": 4500
}If the product ID is not found:
{
"mensagem": "ID not found!"
}DELETE /apagar/{id}
{
"mensagem": "Product removed!"
}If the product ID is not found:
{
"mensagem": "ID not found!"
}.
├── app.py
└── README.md
- 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.
Developed as part of a SENAI course to learn the fundamentals of REST API development using Python.