Compare commits
2 commits
564bac8ea4
...
3926729e0c
| Author | SHA1 | Date | |
|---|---|---|---|
| 3926729e0c | |||
| f36272a6c0 |
5 changed files with 14 additions and 9 deletions
|
|
@ -40,7 +40,7 @@ def get_ttl_hash() -> int:
|
||||||
https://stackoverflow.com/a/55900800
|
https://stackoverflow.com/a/55900800
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return round(time() / SETTINGS.cache_seconds)
|
return round(time() / SETTINGS.cache_time)
|
||||||
|
|
||||||
|
|
||||||
def timed_alru_cache(*decorator_args, **decorator_kwargs):
|
def timed_alru_cache(*decorator_args, **decorator_kwargs):
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ def main() -> None:
|
||||||
if webdav_check():
|
if webdav_check():
|
||||||
uvicorn_run(
|
uvicorn_run(
|
||||||
app="ovdashboard_api.main:app",
|
app="ovdashboard_api.main:app",
|
||||||
host="0.0.0.0",
|
host=SETTINGS.main_host,
|
||||||
port=8000,
|
port=SETTINGS.main_port,
|
||||||
reload=not SETTINGS.production_mode,
|
reload=not SETTINGS.production_mode,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,16 @@ from fastapi import APIRouter
|
||||||
from ..settings import SETTINGS
|
from ..settings import SETTINGS
|
||||||
from . import aggregate, calendar, image, misc, text, ticker
|
from . import aggregate, calendar, image, misc, text, ticker
|
||||||
|
|
||||||
main_router = APIRouter(prefix=f"/{SETTINGS.api_v1_prefix}")
|
main_router = APIRouter(prefix=f"/{SETTINGS.api_prefix}")
|
||||||
|
|
||||||
|
main_router.include_router(misc.router)
|
||||||
|
|
||||||
main_router.include_router(text.router)
|
main_router.include_router(text.router)
|
||||||
main_router.include_router(ticker.router)
|
main_router.include_router(ticker.router)
|
||||||
main_router.include_router(image.router)
|
main_router.include_router(image.router)
|
||||||
|
|
||||||
main_router.include_router(calendar.router)
|
main_router.include_router(calendar.router)
|
||||||
main_router.include_router(aggregate.router)
|
main_router.include_router(aggregate.router)
|
||||||
main_router.include_router(misc.router)
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"main_router",
|
"main_router",
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ async def get_ip() -> str:
|
||||||
) as s:
|
) as s:
|
||||||
s.settimeout(0)
|
s.settimeout(0)
|
||||||
try:
|
try:
|
||||||
s.connect((SETTINGS.ping_address, SETTINGS.ping_port))
|
s.connect((SETTINGS.ping_host, SETTINGS.ping_port))
|
||||||
IP = s.getsockname()[0]
|
IP = s.getsockname()[0]
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
||||||
|
|
@ -49,14 +49,16 @@ class Settings(BaseSettings):
|
||||||
|
|
||||||
production_mode: bool = False
|
production_mode: bool = False
|
||||||
log_level: str = "INFO" if production_mode else "DEBUG"
|
log_level: str = "INFO" if production_mode else "DEBUG"
|
||||||
cache_seconds: int = 30
|
cache_time: int = 30
|
||||||
cache_size: int = 30
|
cache_size: int = 30
|
||||||
|
|
||||||
# doesn't even have to be reachable
|
# doesn't even have to be reachable
|
||||||
ping_address: str = "10.0.0.0"
|
ping_host: str = "10.0.0.0"
|
||||||
ping_port: int = 1
|
ping_port: int = 1
|
||||||
|
|
||||||
api_v1_prefix: str = "api/v1"
|
main_host: str = "0.0.0.0"
|
||||||
|
main_port: int = 8000
|
||||||
|
api_prefix: str = "api/v1"
|
||||||
openapi_url: str = "/openapi.json"
|
openapi_url: str = "/openapi.json"
|
||||||
docs_url: Optional[str] = None if production_mode else "/docs"
|
docs_url: Optional[str] = None if production_mode else "/docs"
|
||||||
redoc_url: Optional[str] = None if production_mode else "/redoc"
|
redoc_url: Optional[str] = None if production_mode else "/redoc"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue