1
0
Fork 0

svc: api: Get URLs file path from env var

The `HUDCTRL_URLS_FILE` environment variable can be used to specify the
location to the `urls.json` file.
Dustin 2022-08-01 22:14:06 -05:00
parent 439db2626b
commit 38b91073f8
1 changed files with 8 additions and 1 deletions

View File

@ -1,9 +1,11 @@
import io import io
import logging import logging
import os
from pathlib import Path
from typing import Optional from typing import Optional
import fastapi
from PIL import Image from PIL import Image
import fastapi
from .hud import HUDService, NoMonitorConfig from .hud import HUDService, NoMonitorConfig
from .xrandr import MonitorConfig from .xrandr import MonitorConfig
@ -15,11 +17,16 @@ log = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
HUDCTRL_URLS_FILE = os.environ.get('HUDCTRL_URLS_FILE')
app = fastapi.FastAPI( app = fastapi.FastAPI(
docs_url='/api-doc/', docs_url='/api-doc/',
) )
svc = HUDService() svc = HUDService()
if HUDCTRL_URLS_FILE:
svc.urls_file = Path(HUDCTRL_URLS_FILE)
class PNGImageResponse(fastapi.Response): class PNGImageResponse(fastapi.Response):