alessandro trinca tornidor
commited on
Commit
·
a8085eb
1
Parent(s):
a22a73a
feat: use os.getenv() the right way with load_dotenv() within constant.py
Browse files- app.py +0 -3
- my_ghost_writer/constants.py +3 -1
app.py
CHANGED
|
@@ -1,6 +1,4 @@
|
|
| 1 |
import json
|
| 2 |
-
import os
|
| 3 |
-
from dotenv import load_dotenv
|
| 4 |
|
| 5 |
from asgi_correlation_id import CorrelationIdMiddleware
|
| 6 |
from fastapi import FastAPI
|
|
@@ -13,7 +11,6 @@ from my_ghost_writer.constants import ALLOWED_ORIGIN_LIST, DOMAIN, IS_TESTING, L
|
|
| 13 |
from my_ghost_writer.type_hints import RequestTextFrequencyBody
|
| 14 |
|
| 15 |
|
| 16 |
-
load_dotenv()
|
| 17 |
fastapi_title = "My Ghost Writer"
|
| 18 |
app = FastAPI(title=fastapi_title, version="1.0")
|
| 19 |
app_logger.info(f"allowed_origins:{ALLOWED_ORIGIN_LIST}...")
|
|
|
|
| 1 |
import json
|
|
|
|
|
|
|
| 2 |
|
| 3 |
from asgi_correlation_id import CorrelationIdMiddleware
|
| 4 |
from fastapi import FastAPI
|
|
|
|
| 11 |
from my_ghost_writer.type_hints import RequestTextFrequencyBody
|
| 12 |
|
| 13 |
|
|
|
|
| 14 |
fastapi_title = "My Ghost Writer"
|
| 15 |
app = FastAPI(title=fastapi_title, version="1.0")
|
| 16 |
app_logger.info(f"allowed_origins:{ALLOWED_ORIGIN_LIST}...")
|
my_ghost_writer/constants.py
CHANGED
|
@@ -2,13 +2,15 @@ import os
|
|
| 2 |
from pathlib import Path
|
| 3 |
import structlog
|
| 4 |
|
|
|
|
| 5 |
from my_ghost_writer import session_logger
|
| 6 |
|
| 7 |
|
|
|
|
| 8 |
PROJECT_ROOT_FOLDER = Path(__file__).parent.parent
|
| 9 |
STATIC_FOLDER = PROJECT_ROOT_FOLDER / "static"
|
| 10 |
DOMAIN=os.getenv("DOMAIN", "localhost")
|
| 11 |
-
PORT=os.getenv("PORT", 7860)
|
| 12 |
ALLOWED_ORIGIN_LIST = os.getenv('ALLOWED_ORIGIN', f'http://{DOMAIN}:{PORT}').split(",")
|
| 13 |
LOG_JSON_FORMAT = bool(os.getenv("LOG_JSON_FORMAT"))
|
| 14 |
IS_TESTING = bool(os.getenv('IS_TESTING', ""))
|
|
|
|
| 2 |
from pathlib import Path
|
| 3 |
import structlog
|
| 4 |
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
from my_ghost_writer import session_logger
|
| 7 |
|
| 8 |
|
| 9 |
+
load_dotenv()
|
| 10 |
PROJECT_ROOT_FOLDER = Path(__file__).parent.parent
|
| 11 |
STATIC_FOLDER = PROJECT_ROOT_FOLDER / "static"
|
| 12 |
DOMAIN=os.getenv("DOMAIN", "localhost")
|
| 13 |
+
PORT=int(os.getenv("PORT", 7860))
|
| 14 |
ALLOWED_ORIGIN_LIST = os.getenv('ALLOWED_ORIGIN', f'http://{DOMAIN}:{PORT}').split(",")
|
| 15 |
LOG_JSON_FORMAT = bool(os.getenv("LOG_JSON_FORMAT"))
|
| 16 |
IS_TESTING = bool(os.getenv('IS_TESTING', ""))
|