This is a sample CRUD (Create, Read, Update, Delete) application developed in Python using the Flask framework. The API allows managing pet information, such as adding, listing, updating, and deleting data.
- Add a Pet: Add new pets to the system.
- List All Pets: Get a complete list of registered pets.
- Update Pet Information: Update data for a specific pet by ID.
- Delete a Pet: Remove a pet from the system using its ID.
- Python - Main programming language.
- Flask - Framework for building the API.
- JSON - For data exchange between client and server.
- Clone the repository:
git clone https://github.com/dgirotto0/api-crud-python.git- Access the project directory:
cd api-crud-python
- Install the required dependencies: Make sure Flask is installed. If not, install it with:
pip install flask
- Start the application:
python pet.py
Access the API via browser or tools like Postman:
http://127.0.0.1:5000
- Route:
/adicionar_pet - Method: POST
- Description: Adds a new pet.
- JSON Example:
{
"nome": "Rex",
"tipo": "Cachorro",
"idade": 3
}- Route:
/listar_pets - Method: GET
- Description: Returns all registered pets.
- Route:
/atualizar_pet/<id> - Method: PUT
- Description: Updates information for a specific pet.
- JSON Example:
{
"nome": "Rex",
"tipo": "Cachorro",
"idade": 4
}- Route:
/excluir_pet/<id> - Method: DELETE
- Description: Removes a pet by ID.
The code is simple and organized in a single class containing the API routes. It uses an in-memory list to store data, ideal for demonstration purposes.
This project is licensed under the MIT License. See the LICENSE file for more details.