Updating README.md file

هذا الالتزام موجود في:
ahmedgamalyousef
2025-09-30 23:30:46 +03:00
الأصل 12ebec097c
التزام 41ba57fccc

عرض الملف

@@ -1,7 +1,8 @@
# 🍎 Fruit Store API
A simple **RESTful API** built with Flask that manages fruits in a store.
The project also includes **logging**, a **log monitoring script**, and **automated testing script**.
The project also includes **logging**, a **log monitoring script**, and **automated testing script** with clear pass/fail output.
---
## 📂 Project Structure
@@ -12,21 +13,21 @@ fruit-api/
│── Dockerfile # Docker support
│── log_monitor.sh # Log monitoring script
│── test_api.sh # Automated testing script
│── test_results.log # API test logs
│── fruit_api.log # API logs
│── README.md # Documentation
│── .gitignore # Ignore venv/logs
```
## 📌 Features
- CRUD operations on fruits (`GET`, `POST`, `PUT`, `DELETE`)
- Search fruits by name
- Filter fruits by category
- Health check endpoint
- Logging of all requests & responses to `fruit_api.log`
- Bash script for monitoring logs (`log_monitor.sh`)
- Bash script for automated API testing (`test_api.sh`)
- Swagger/OpenAPI documentation
- Bash script for monitoring logs (`log_monitor.sh`) with **error alerts (4xx/5xx)**
- Bash script for automated API testing (`test_api.sh`) with ✅ / ❌ results
- Swagger/OpenAPI documentation at `/docs`
---
@@ -92,12 +93,12 @@ curl http://localhost:5000/fruits
- **Add a fruit**
```bash
curl -X POST http://localhost:5000/fruits -H "Content-Type: application/json" -d '{"name":"Mango","color":"Yellow","price":2.5,"quantity":50,"category":"Tropical"}'
curl -X POST http://localhost:5000/fruits -H "Content-Type: application/json" -d '{"name":"Mango","color":"Yellow","price":2.5,"quantity":50,"category":"Tropical"}'
```
- **Update a fruit**
```bash
curl -X PUT http://localhost:5000/fruits/1 -H "Content-Type: application/json" -d '{"name":"Green Apple","price":1.8}'
curl -X PUT http://localhost:5000/fruits/1 -H "Content-Type: application/json" -d '{"name":"Green Apple","price":1.8}'
```
---
@@ -135,6 +136,7 @@ bash log_monitor.sh &
The `test_api.sh` script:
- Runs automated `GET`, `POST`, `PUT`, `DELETE` requests
- Prints ✅ if the status is correct (200/201), ❌ otherwise
- Logs results in `test_results.log`
Run tests:
@@ -142,6 +144,17 @@ Run tests:
bash test_api.sh
```
Example output:
```
🚀 Running API tests at Tue 30 Sep 2025 10:54:01 PM EEST
🔹 Testing /health ... ✅
🔹 Testing GET /fruits ... ✅
🔹 Testing POST /fruits ... ✅
🔹 Testing PUT /fruits/1 ... ✅
🔹 Testing DELETE /fruits/1 ... ✅
✅ All tests passed!
```
---
## 📘 Swagger Documentation
@@ -160,7 +173,3 @@ docker build -t fruit-api .
### Run container
```bash
docker run -p 5000:5000 fruit-api
```
---