Spaces:
Running
Running
Commit
·
a00a37a
1
Parent(s):
817c011
Better way to access secrets
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
|
|
| 1 |
import logging
|
| 2 |
from contextlib import asynccontextmanager
|
| 3 |
from enum import Enum
|
| 4 |
-
from pathlib import Path
|
| 5 |
|
| 6 |
from arcana_codex import (
|
| 7 |
AdUnitsFetchModel,
|
|
@@ -37,11 +37,7 @@ logger = logging.getLogger(__name__)
|
|
| 37 |
@asynccontextmanager
|
| 38 |
async def lifespan(app: FastAPI): # noqa: ARG001
|
| 39 |
# Set API key in FastAPI app
|
| 40 |
-
app.ARCANA_API_KEY = (
|
| 41 |
-
Path("/run/secrets/ARCANA_API_KEY").read_text().splitlines()[0]
|
| 42 |
-
if len(Path("/run/secrets/ARCANA_API_KEY").read_text().splitlines()) > 0
|
| 43 |
-
else ""
|
| 44 |
-
)
|
| 45 |
|
| 46 |
logging.info("Application started")
|
| 47 |
|
|
|
|
| 1 |
+
import os
|
| 2 |
import logging
|
| 3 |
from contextlib import asynccontextmanager
|
| 4 |
from enum import Enum
|
|
|
|
| 5 |
|
| 6 |
from arcana_codex import (
|
| 7 |
AdUnitsFetchModel,
|
|
|
|
| 37 |
@asynccontextmanager
|
| 38 |
async def lifespan(app: FastAPI): # noqa: ARG001
|
| 39 |
# Set API key in FastAPI app
|
| 40 |
+
app.ARCANA_API_KEY = os.environ.get("ARCANA_API_KEY", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
logging.info("Application started")
|
| 43 |
|