Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
7f52eba875
commit
6a64c47868
39
endpoints/api/v1/endpoint.post.py
Normal file
39
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
from core.database import fake_users_db
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/endpoint")
|
||||||
|
async def distance_handler(
|
||||||
|
start_point: str,
|
||||||
|
end_point: str,
|
||||||
|
unit: Optional[str] = "km"
|
||||||
|
):
|
||||||
|
"""Calculate distance between two points"""
|
||||||
|
if not start_point or not end_point:
|
||||||
|
raise HTTPException(status_code=400, detail="Both start and end points are required")
|
||||||
|
|
||||||
|
if unit not in ["km", "miles", "meters"]:
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid unit. Must be km, miles, or meters")
|
||||||
|
|
||||||
|
# Demo calculation - would be replaced with actual distance calculation
|
||||||
|
demo_distances = {
|
||||||
|
"km": 100,
|
||||||
|
"miles": 62.1371,
|
||||||
|
"meters": 100000
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
"message": "Distance calculated successfully",
|
||||||
|
"data": {
|
||||||
|
"start_point": start_point,
|
||||||
|
"end_point": end_point,
|
||||||
|
"distance": demo_distances[unit],
|
||||||
|
"unit": unit
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"calculation_method": "demo",
|
||||||
|
"accuracy": "approximate"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user