Fix mypy issue to catch situation where we might not have a client address
All checks were successful
All checks were successful
This commit is contained in:
@ -7,7 +7,8 @@ from typing import Annotated, Optional, Union
|
|||||||
|
|
||||||
import geoip2.database
|
import geoip2.database
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from fastapi import Body, FastAPI, Path, Request, Response, status
|
from fastapi import (Body, FastAPI, HTTPException, Path, Request, Response,
|
||||||
|
status)
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.responses import RedirectResponse
|
from fastapi.responses import RedirectResponse
|
||||||
from geoip2.errors import AddressNotFoundError
|
from geoip2.errors import AddressNotFoundError
|
||||||
@ -126,4 +127,6 @@ def root_redirect(req: Request) -> RedirectResponse:
|
|||||||
'''
|
'''
|
||||||
Redirect empty request using REMOTE_ADDR
|
Redirect empty request using REMOTE_ADDR
|
||||||
'''
|
'''
|
||||||
|
if not req.client:
|
||||||
|
raise HTTPException(status_code=404, detail="Item not found")
|
||||||
return RedirectResponse(url=str(req.url) + str(req.client.host))
|
return RedirectResponse(url=str(req.url) + str(req.client.host))
|
||||||
|
|||||||
Reference in New Issue
Block a user