Skip to content

Commit

Permalink
return main page for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
optk2k committed Dec 13, 2023
1 parent 4d766b1 commit 9fca47b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions df_designer/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path
import aiofiles
import dff
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
Expand All @@ -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)


Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 9fca47b

Please sign in to comment.