osr proxy
This commit is contained in:
@@ -66,3 +66,8 @@ class iCloudReturnData(BaseModel):
|
||||
class LatLng(BaseModel):
|
||||
latitude: float
|
||||
longitude: float
|
||||
|
||||
class ORSRequest(BaseModel):
|
||||
geometry_simplify: bool
|
||||
coordinates: List[List[float]]
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user