fix(core): remove old static landing page from Docker image (#9369)
The "Experience the new ADE" page was outdated and no longer useful. Root path now redirects to /docs (FastAPI Swagger UI) instead. 👾 Generated with [Letta Code](https://letta.com) Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
committed by
Caren Thomas
parent
80a0d1a95f
commit
c32d53f8a3
@@ -1,74 +1,8 @@
|
||||
import importlib.util
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.responses import FileResponse
|
||||
from starlette.exceptions import HTTPException as StarletteHTTPException
|
||||
from starlette.staticfiles import StaticFiles
|
||||
|
||||
|
||||
class SPAStaticFiles(StaticFiles):
|
||||
async def get_response(self, path: str, scope):
|
||||
try:
|
||||
return await super().get_response(path, scope)
|
||||
except (HTTPException, StarletteHTTPException) as ex:
|
||||
if ex.status_code == 404:
|
||||
return await super().get_response("index.html", scope)
|
||||
else:
|
||||
raise ex
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import RedirectResponse
|
||||
|
||||
|
||||
def mount_static_files(app: FastAPI):
|
||||
static_files_path = os.path.join(os.path.dirname(importlib.util.find_spec("letta").origin), "server", "static_files")
|
||||
if os.path.exists(static_files_path):
|
||||
app.mount("/assets", StaticFiles(directory=os.path.join(static_files_path, "assets")), name="assets")
|
||||
|
||||
@app.get("/letta_logo_transparent.png", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "letta_logo_transparent.png"))
|
||||
|
||||
@app.get("/", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
|
||||
@app.get("/agents", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
|
||||
@app.get("/data-sources", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
|
||||
@app.get("/tools", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
|
||||
@app.get("/agent-templates", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
|
||||
@app.get("/human-templates", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
|
||||
@app.get("/settings/profile", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
|
||||
@app.get("/agents/{agent-id}/chat", include_in_schema=False)
|
||||
async def serve_spa():
|
||||
return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
|
||||
|
||||
# def mount_static_files(app: FastAPI):
|
||||
# static_files_path = os.path.join(os.path.dirname(importlib.util.find_spec("letta").origin), "server", "static_files")
|
||||
# if os.path.exists(static_files_path):
|
||||
|
||||
# @app.get("/{full_path:path}")
|
||||
# async def serve_spa(full_path: str):
|
||||
# if full_path.startswith("v1"):
|
||||
# raise HTTPException(status_code=404, detail="Not found")
|
||||
# file_path = os.path.join(static_files_path, full_path)
|
||||
# if os.path.isfile(file_path):
|
||||
# return FileResponse(file_path)
|
||||
# return FileResponse(os.path.join(static_files_path, "index.html"))
|
||||
@app.get("/", include_in_schema=False)
|
||||
async def redirect_to_docs():
|
||||
return RedirectResponse(url="/docs")
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 342 B |
@@ -1,39 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Letta</title>
|
||||
<base href="/" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
|
||||
<script>
|
||||
if (localStorage.theme === 'dark') {
|
||||
if (document && document.documentElement) {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
} else if (localStorage.theme === 'light') {
|
||||
if (document && document.documentElement) {
|
||||
document.documentElement.classList.remove('dark');
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
} else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
localStorage.setItem('theme', 'system');
|
||||
if (document && document.documentElement) {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
} else {
|
||||
if (document && document.documentElement) {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="module" crossorigin src="/assets/index-048c9598.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-0e31b727.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="h-full w-full" id="root"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 83 KiB |
Reference in New Issue
Block a user