geo-access
This commit is contained in:
parent
686e395fcd
commit
8a87a78449
6 changed files with 117 additions and 6 deletions
0
backend/endpoints/__init__.py
Normal file
0
backend/endpoints/__init__.py
Normal file
33
backend/endpoints/geo_access.py
Normal file
33
backend/endpoints/geo_access.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
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}
|
Loading…
Add table
Add a link
Reference in a new issue