fix: mount bug.

This commit is contained in:
EstrellaXD
2023-10-05 01:01:07 +08:00
parent a69d832801
commit 2328fe3c73
2 changed files with 8 additions and 3 deletions

View File

@@ -36,7 +36,12 @@ def create_app() -> FastAPI:
app = create_app()
app.mount("/posters", StaticFiles(directory="data/posters"), name="posters")
@app.get("/posters/{path:path}", tags=["posters"])
def posters(path: str):
return FileResponse(f"data/posters/{path}")
if VERSION != "DEV_VERSION":
app.mount("/assets", StaticFiles(directory="dist/assets"), name="assets")
@@ -63,7 +68,6 @@ if __name__ == "__main__":
host = "::"
else:
host = os.getenv("HOST", "0.0.0.0")
os.mkdir("data/posters") if not os.path.exists("data/posters") else None
uvicorn.run(
app,
host=host,

View File

@@ -79,7 +79,8 @@ class Checker:
def check_img_cache() -> bool:
img_path = Path("data/posters")
# If poster folder is not empty, return True
if list(img_path.glob("*")):
if img_path.exists():
return True
else:
img_path.mkdir()
return False