mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
added mime typing
This commit is contained in:
parent
e7e4bb8d21
commit
9179494972
13
app.py
13
app.py
@ -7,6 +7,7 @@ This file is the entry point to the webui.
|
||||
"""
|
||||
from fastapi import FastAPI
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from starlette.responses import FileResponse
|
||||
from fastapi.responses import HTMLResponse
|
||||
from lollms.app import LollmsApplication
|
||||
from lollms.paths import LollmsPaths
|
||||
@ -222,6 +223,18 @@ if __name__ == "__main__":
|
||||
app.mount("/extensions", StaticFiles(directory=Path(__file__).parent/"web"/"dist", html=True), name="extensions")
|
||||
app.mount("/playground", StaticFiles(directory=Path(__file__).parent/"web"/"dist", html=True), name="playground")
|
||||
app.mount("/settings", StaticFiles(directory=Path(__file__).parent/"web"/"dist", html=True), name="settings")
|
||||
|
||||
# Custom route to serve JavaScript files with the correct MIME type
|
||||
@app.get("/{path:path}")
|
||||
async def serve_js(path: str):
|
||||
if path=="":
|
||||
return FileResponse(Path(__file__).parent / "web" / "dist" / "index.html", media_type="text/html")
|
||||
file_path = Path(__file__).parent / "web" / "dist" / path
|
||||
if file_path.suffix == ".js":
|
||||
return FileResponse(file_path, media_type="application/javascript")
|
||||
return FileResponse(file_path)
|
||||
|
||||
|
||||
app.mount("/", StaticFiles(directory=Path(__file__).parent/"web"/"dist", html=True), name="static")
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 654ebcfb32819d5418a5622460b602d77daf3eb9
|
||||
Subproject commit 0a10f39fe33d6a40e47be79b3634224c75ab2130
|
Loading…
Reference in New Issue
Block a user