diff --git a/df_designer/main.py b/df_designer/main.py index fb7f45e5..f95a186e 100644 --- a/df_designer/main.py +++ b/df_designer/main.py @@ -1,3 +1,5 @@ +from pathlib import Path +import aiofiles import dff from fastapi import FastAPI, Request from fastapi.responses import HTMLResponse @@ -16,8 +18,13 @@ @app.get("/") async def main_page() -> HTMLResponse: - """Main.""" - html = "main page" + """Return frontend.""" + start_page = "static/index.html" + if not Path(start_page).exists(): + html = "frontend is not build" + else: + async with aiofiles.open(start_page) as file: + html = await file.read() return HTMLResponse(content=html, status_code=200) @@ -117,6 +124,7 @@ async def library_llms_get() -> dict[str, str]: """(get available llm models) - JSON of llm models""" return {"status": "ok"} + # TODO: rename runtime (здесь нет DFF, здесь используются модели) # /dff @app.post("/dff/tests/prompt") diff --git a/tests/test_main.py b/tests/test_main.py index 7f37c8fb..21774172 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -23,6 +23,7 @@ def test_main_save(): response = client.post("/save", json={"key": "value"}) assert response.status_code == 200 assert response.json() == {"status": "ok"} + Path(settings.path_to_save).unlink() def test_main_get():