Compare commits
2 Commits
0b4322d671
...
1fa64feefc
Author | SHA1 | Date | |
---|---|---|---|
1fa64feefc | |||
f78ed7592d |
10
app/main.py
10
app/main.py
@ -6,7 +6,8 @@ from typing import Annotated, Optional, Union
|
|||||||
|
|
||||||
import geoip2.database
|
import geoip2.database
|
||||||
from geoip2.errors import AddressNotFoundError
|
from geoip2.errors import AddressNotFoundError
|
||||||
from fastapi import FastAPI, Path, Body, Response, status
|
from fastapi import FastAPI, Path, Body, Request, Response, status
|
||||||
|
from fastapi.responses import RedirectResponse
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
@ -87,3 +88,10 @@ async def root_get(ipaddress: Annotated[Union[IPv4Address,IPv6Address],
|
|||||||
return locations.pop()
|
return locations.pop()
|
||||||
response.status_code = status.HTTP_404_NOT_FOUND
|
response.status_code = status.HTTP_404_NOT_FOUND
|
||||||
return GeoLocation()
|
return GeoLocation()
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
def root_redirect(req: Request) -> RedirectResponse:
|
||||||
|
'''
|
||||||
|
Redirect empty request using REMOTE_ADDR
|
||||||
|
'''
|
||||||
|
return RedirectResponse(url= str(req.url) + str(req.client.host))
|
||||||
|
0
run/.gitkeep
Normal file
0
run/.gitkeep
Normal file
24
start.sh
Executable file
24
start.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
NAME=ismijnipverweg
|
||||||
|
DIR=/opt/apps/ismijnipverweg/app
|
||||||
|
USER=www
|
||||||
|
GROUP=nobody
|
||||||
|
WORKERS=3
|
||||||
|
WORKER_CLASS=uvicorn.workers.UvicornWorker
|
||||||
|
#VENV=$DIR/.venv/bin/activate
|
||||||
|
BIND=unix:$DIR/../run/gunicorn.sock
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
cd $DIR
|
||||||
|
# source $VENV
|
||||||
|
|
||||||
|
exec gunicorn main:app \
|
||||||
|
--name $NAME \
|
||||||
|
--workers $WORKERS \
|
||||||
|
--worker-class $WORKER_CLASS \
|
||||||
|
--user=$USER \
|
||||||
|
--group=$GROUP \
|
||||||
|
--bind=$BIND \
|
||||||
|
--log-level=$LOG_LEVEL \
|
||||||
|
--log-file=-
|
Loading…
x
Reference in New Issue
Block a user