fix latin-1 errors
This commit is contained in:
14
app/main.py
14
app/main.py
@@ -2,7 +2,7 @@ from fastapi import FastAPI, Request, Response
|
||||
from fastapi.responses import JSONResponse, PlainTextResponse
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from .deps import get_geo
|
||||
from .api import get_client_ip, router
|
||||
from .api import get_client_ip, router, geo_headers
|
||||
from .config import settings
|
||||
import uvicorn
|
||||
|
||||
@@ -17,16 +17,8 @@ async def add_geo_headers(request, call_next):
|
||||
|
||||
response: Response = await call_next(request)
|
||||
|
||||
country = data.get("country", {}).get("name") if data.get("country") else None
|
||||
city = data.get("city")
|
||||
ip_val = data.get("ip")
|
||||
|
||||
if ip_val and country:
|
||||
response.headers["X-IP-ADDRESS"] = ip_val
|
||||
response.headers["X-COUNTRY"] = country
|
||||
if city:
|
||||
response.headers["X-CITY"] = city
|
||||
|
||||
for k, v in geo_headers(data).items():
|
||||
response.headers[k] = v
|
||||
return response
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user