changed structure for docker usage
This commit is contained in:
34
app/main.py
34
app/main.py
@@ -25,17 +25,15 @@ import mariadb
|
||||
|
||||
import filetype
|
||||
|
||||
import datetime
|
||||
|
||||
import logging
|
||||
import inspect
|
||||
import pathlib
|
||||
|
||||
from starlette.types import HTTPExceptionHandler
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
logging.basicConfig(
|
||||
filename="app.log",
|
||||
filename=os.environ.get("APP_LOG_PATH"),
|
||||
level=logging.INFO,
|
||||
format="[%(asctime)s, %(filename)s:%(lineno)s -> %(funcName)10s() ]%(levelname)s: %(message)s",
|
||||
)
|
||||
@@ -44,7 +42,10 @@ info = log.info
|
||||
error = log.error
|
||||
|
||||
db = mariadb.connect(
|
||||
host="localhost", user="wildserver", password="DBPassword", database="Unizeug"
|
||||
host=os.environ.get("DB_HOST", "db"),
|
||||
user=os.environ.get("DB_USER", "user"),
|
||||
password=os.environ.get("DB_PASSWORD", "DBPASSWORD"),
|
||||
database=os.environ.get("DB_DATABASE", "unizeug"),
|
||||
)
|
||||
|
||||
info("App Started")
|
||||
@@ -53,8 +54,16 @@ info("App Started")
|
||||
|
||||
# startup()
|
||||
app = FastAPI()
|
||||
app.mount("/favicon", StaticFiles(directory="./favicon"), name="favicon")
|
||||
app.mount("/static", StaticFiles(directory="./static"), name="static")
|
||||
app.mount(
|
||||
"/favicon",
|
||||
StaticFiles(directory=os.environ.get("FAVICON_PATH", ".app/favicon")),
|
||||
name="favicon",
|
||||
)
|
||||
app.mount(
|
||||
"/static",
|
||||
StaticFiles(directory=os.environ.get("STATIC_PATH", "./static")),
|
||||
name="static",
|
||||
)
|
||||
|
||||
|
||||
CATEGORIES = [
|
||||
@@ -66,15 +75,16 @@ CATEGORIES = [
|
||||
"Zusammenfassungen",
|
||||
"Multimedia",
|
||||
]
|
||||
APP_ROOT_PATH = os.environ.get("APP_ROOT_PATH", "./app")
|
||||
SUBCAT_CATEGORIES = ["Klausuren", "Übungen", "Labore"]
|
||||
SUBCAT_CATEGORIES_I = [1, 2, 3]
|
||||
EX_DATE_CATEGORIES = ["Prüfungen", "Klausuren"]
|
||||
EX_DATE_CATEGORIES_I = [0, 1]
|
||||
UNIZEUG_PATH = "./app/dest/"
|
||||
FILES_IN_PROGRESS = "./app/files/"
|
||||
EMPTYFILE = "./app/graphics/empty.pdf"
|
||||
UNSUPPORTEDFILE = "./app/graphics/unsupported.pdf"
|
||||
GREETINGFILE = "./app/graphics/greeting.pdf"
|
||||
UNIZEUG_PATH = os.environ.get("UNIZEUG_PATH", "./app/dest")
|
||||
FILES_IN_PROGRESS = f"{APP_ROOT_PATH}/files/"
|
||||
EMPTYFILE = f"{APP_ROOT_PATH}/graphics/empty.pdf"
|
||||
UNSUPPORTEDFILE = f"{APP_ROOT_PATH}/graphics/unsupported.pdf"
|
||||
GREETINGFILE = f"{APP_ROOT_PATH}/graphics/greeting.pdf"
|
||||
|
||||
|
||||
# cur = db.cursor()
|
||||
@@ -151,7 +161,7 @@ def sqlT(
|
||||
@app.get("/")
|
||||
async def get_index():
|
||||
"""gives the Index.html file"""
|
||||
return FileResponse("./index.html")
|
||||
return FileResponse(f"{APP_ROOT_PATH}/index.html")
|
||||
|
||||
|
||||
@app.get("/files/{file_id}")
|
||||
|
||||
Reference in New Issue
Block a user