33 lines
766 B
Python
33 lines
766 B
Python
from dataclasses import dataclass
|
|
from typing import Literal, TypedDict
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from geo_access import lido_circle_checker
|
|
|
|
geo_access_router = APIRouter(prefix="/geo-access")
|
|
|
|
@dataclass
|
|
class GeoAccessRequest:
|
|
"""
|
|
Request model for geo access.
|
|
"""
|
|
coords: tuple[float, float]
|
|
# type: Literal["circle", "polygon"] | None = "circle"
|
|
|
|
|
|
type_checker = {
|
|
"circle": lido_circle_checker,
|
|
# "polygon": lido_polygon_checker
|
|
}
|
|
|
|
|
|
@geo_access_router.post("/")
|
|
async def get_geo_access(request: GeoAccessRequest):
|
|
with open("test.json", "w") as f:
|
|
f.write(repr(request))
|
|
|
|
# return {
|
|
# "success": type_checker.get(request.type, "circle").is_inside(request.coords)
|
|
# }
|
|
return {"success": True}
|