Use full path for the static directory in FastAPI and reflect deeper nesting of the django app

This commit is contained in:
sabaimran 2023-11-21 13:44:45 -08:00
parent 6d9091bef5
commit 5469e81a87
2 changed files with 4 additions and 4 deletions

View file

@ -14,7 +14,7 @@ from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
@ -143,7 +143,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_ROOT = BASE_DIR / "static"
STATICFILES_DIRS = [BASE_DIR / "src/khoj/interface/web"]
STATICFILES_DIRS = [BASE_DIR / "interface/web"]
STATIC_URL = "/static/"
# Default primary key field type

View file

@ -107,10 +107,10 @@ def run(should_start_server=True):
# Mount Django and Static Files
app.mount("/server", django_app, name="server")
static_dir = "static"
static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static")
if not os.path.exists(static_dir):
os.mkdir(static_dir)
app.mount(f"/{static_dir}", StaticFiles(directory=static_dir), name=static_dir)
app.mount(f"/static", StaticFiles(directory=static_dir), name=static_dir)
# Configure Middleware
configure_middleware(app)