34 lines
795 B
Python
34 lines
795 B
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
prices = [] # In-memory storage
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/petrol-price")
|
|
async def update_petrol_price(
|
|
price: float = 650.00,
|
|
state: str = "Lagos",
|
|
station: str = "NNPC"
|
|
):
|
|
"""Update petrol price endpoint"""
|
|
if price <= 0:
|
|
raise HTTPException(status_code=400, detail="Invalid price amount")
|
|
|
|
prices.append({
|
|
"price_per_litre": price,
|
|
"state": state,
|
|
"station": station,
|
|
"currency": "NGN",
|
|
"last_updated": "2024-01-19"
|
|
})
|
|
|
|
return {
|
|
"message": "Price updated successfully",
|
|
"price": price,
|
|
"state": state,
|
|
"station": station,
|
|
"features": {
|
|
"rate_limit": 100,
|
|
"expires_in": 3600
|
|
}
|
|
} |