From c31a9c01b65d8f4dbbdb2af6206c3c77c3e2f29e Mon Sep 17 00:00:00 2001 From: William Bruno Date: Sat, 4 Apr 2026 11:28:57 -0400 Subject: [PATCH] osr proxy --- src/pymd3_vue_location_sim/models.py | 5 +++++ src/pymd3_vue_location_sim/server.py | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pymd3_vue_location_sim/models.py b/src/pymd3_vue_location_sim/models.py index 3895dad..212dd1c 100644 --- a/src/pymd3_vue_location_sim/models.py +++ b/src/pymd3_vue_location_sim/models.py @@ -66,3 +66,8 @@ class iCloudReturnData(BaseModel): class LatLng(BaseModel): latitude: float longitude: float + +class ORSRequest(BaseModel): + geometry_simplify: bool + coordinates: List[List[float]] + diff --git a/src/pymd3_vue_location_sim/server.py b/src/pymd3_vue_location_sim/server.py index 96fcb3e..58aff1c 100644 --- a/src/pymd3_vue_location_sim/server.py +++ b/src/pymd3_vue_location_sim/server.py @@ -10,6 +10,7 @@ import warnings import random import math import socketio +import httpx from contextlib import asynccontextmanager, suppress from typing import Optional, Dict from dotenv import load_dotenv @@ -19,7 +20,7 @@ with warnings.catch_warnings(): warnings.simplefilter("ignore", category=UserWarning) import fastapi import uvicorn -from fastapi import FastAPI, APIRouter +from fastapi import FastAPI, APIRouter, Request from fastapi.encoders import jsonable_encoder from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse @@ -58,7 +59,8 @@ from .models import ( SimulationRequestData, SimulationRequestResponseData, iCloudLocationData, - LatLng + LatLng, + ORSRequest ) from .json_formatter import JsonFormatter, handler, root_logger, logger from .geo_cache import AsyncReverseGeocoder @@ -1300,6 +1302,18 @@ class TunneldRunnerSio: logger.info("Reverse Geocoded %s to %s", coords, rev_geocode) return generate_http_response(rev_geocode) + @self._app.post("/proxy/ors/{full_path:path}") + async def app_proxy_ors(full_path: str, request: Request): + logger.info("request: %s", request) + body = await request.body() + headers = dict(request.headers) + method = request.method + url = "https://ors.intrepidnet.org/" + full_path + + async with httpx.AsyncClient() as client: + response = await client.request(method, url, headers=headers, content=body) + return response.content + """ Socket.IO Functions""" async def sio_send_status(sid):