mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
remove static files from FastAPI
This commit is contained in:
parent
69c5aada04
commit
c5c5e2825f
2 changed files with 15 additions and 53 deletions
|
@ -1,14 +1,22 @@
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.staticfiles import StaticFiles
|
|
||||||
|
|
||||||
# import utils.startup as startup
|
# import utils.startup as startup
|
||||||
from app_config import (APP_VERSION, PORT, PRODUCTION, WEB_PATH, docs_url,
|
from app_config import APP_VERSION, PORT, WEB_PATH, docs_url, redoc_url
|
||||||
redoc_url)
|
from routes import (
|
||||||
from routes import (backup_routes, debug_routes, meal_routes, migration_routes,
|
backup_routes,
|
||||||
setting_routes, static_routes, theme_routes)
|
debug_routes,
|
||||||
from routes.recipe import (all_recipe_routes, category_routes,
|
meal_routes,
|
||||||
recipe_crud_routes, tag_routes)
|
migration_routes,
|
||||||
|
setting_routes,
|
||||||
|
theme_routes,
|
||||||
|
)
|
||||||
|
from routes.recipe import (
|
||||||
|
all_recipe_routes,
|
||||||
|
category_routes,
|
||||||
|
recipe_crud_routes,
|
||||||
|
tag_routes,
|
||||||
|
)
|
||||||
from services.settings_services import default_settings_init
|
from services.settings_services import default_settings_init
|
||||||
from utils.logger import logger
|
from utils.logger import logger
|
||||||
|
|
||||||
|
@ -21,10 +29,6 @@ app = FastAPI(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def mount_static_files():
|
|
||||||
app.mount("/static", StaticFiles(directory=WEB_PATH, html=True))
|
|
||||||
|
|
||||||
|
|
||||||
def start_scheduler():
|
def start_scheduler():
|
||||||
import services.scheduler.scheduled_jobs
|
import services.scheduler.scheduled_jobs
|
||||||
|
|
||||||
|
@ -52,25 +56,7 @@ def api_routers():
|
||||||
app.include_router(debug_routes.router)
|
app.include_router(debug_routes.router)
|
||||||
|
|
||||||
|
|
||||||
if PRODUCTION:
|
|
||||||
pass
|
|
||||||
# mount_static_files()
|
|
||||||
|
|
||||||
api_routers()
|
api_routers()
|
||||||
|
|
||||||
# API 404 Catch all CALL AFTER ROUTERS
|
|
||||||
@app.get("/api/{full_path:path}", status_code=404, include_in_schema=False)
|
|
||||||
def invalid_api():
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
app.include_router(static_routes.router)
|
|
||||||
|
|
||||||
|
|
||||||
# Generate API Documentation
|
|
||||||
# if not PRODUCTION:
|
|
||||||
# generate_api_docs(app)
|
|
||||||
|
|
||||||
start_scheduler()
|
start_scheduler()
|
||||||
init_settings()
|
init_settings()
|
||||||
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from fastapi import APIRouter, responses
|
|
||||||
from fastapi.responses import FileResponse
|
|
||||||
|
|
||||||
CWD = Path(__file__).parent
|
|
||||||
WEB_PATH = CWD.parent.joinpath("dist")
|
|
||||||
BASE_HTML = WEB_PATH.joinpath("index.html")
|
|
||||||
router = APIRouter(include_in_schema=False)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/favicon.ico")
|
|
||||||
def facivon():
|
|
||||||
return responses.RedirectResponse(url="/mealie/favicon.ico")
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/")
|
|
||||||
async def root():
|
|
||||||
return FileResponse(BASE_HTML)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{full_path:path}")
|
|
||||||
async def root_plus(full_path):
|
|
||||||
return FileResponse(BASE_HTML)
|
|
Loading…
Add table
Add a link
Reference in a new issue