Skip to content
Snippets Groups Projects
Commit 942aa86d authored by Grießhaber Daniel's avatar Grießhaber Daniel :squid:
Browse files

add frontend as submodule

parent 79a99169
No related branches found
No related tags found
No related merge requests found
[submodule "frontend"]
path = frontend
url = git@gitlab.mi.hdm-stuttgart.de:griesshaber/evotree.git
from fastapi import FastAPI, Request from fastapi import FastAPI, Request, Response
from fastapi.staticfiles import StaticFiles
from requests import request as make_request
from api.routers import runs
# from api.optimization import Backend # from api.optimization import Backend
DEBUG = True DEBUG = True
app = FastAPI(debug=DEBUG, title="Prompt Optimization Backend") app = FastAPI(debug=DEBUG, title="Prompt Optimization Backend")
app.include_router(runs.router, prefix="/api/runs")
if DEBUG:
@app.get("/{_:path}")
async def frontent_dev(request: Request):
response = make_request(
method=request.method,
url=f"{request.url.replace(port=3000)}",
headers=request.headers,
stream=True,
)
return Response(
content=response.raw.read(),
status_code=response.status_code,
headers=response.headers,
media_type=response.headers["content-type"],
)
else:
app.mount("/", StaticFiles(directory="frontend/build/", html=True), name="frontend")
# api = Backend(debug=DEBUG)
def test(): def test():
pass pass
...@@ -37,8 +60,3 @@ async def evolve(prompt1: str, prompt2: str) -> str: ...@@ -37,8 +60,3 @@ async def evolve(prompt1: str, prompt2: str) -> str:
@app.get("/family_tree/get") @app.get("/family_tree/get")
async def get_family() -> dict: async def get_family() -> dict:
return dict() return dict()
@app.get("/")
def main(request: Request) -> str:
return "server running"
import json
from pathlib import Path
from fastapi import APIRouter
router = APIRouter()
runs_directory = Path("runs")
@router.get("/")
async def list():
return [
run.name
for run in runs_directory.iterdir()
if run.is_dir() and (run / "snapshot.json").exists()
]
@router.get("/{run_name}/")
async def get(run_name: str):
run_path = runs_directory / run_name
snapshot = run_path / "snapshot.json"
return json.load(snapshot.open("r"))
Subproject commit d430de1597342eedf0cede1873507a3ffaa28dbb
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment