Skip to content

Commit 237e53e

Browse files
2 parents 4bf8577 + b75f397 commit 237e53e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

backend/src/api/api.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
This module provides an API for interacting with musical instruments and their finger positions.
33
"""
44

5+
from pathlib import Path
6+
57
from fastapi import FastAPI
68
from fastapi.middleware.cors import CORSMiddleware
9+
from fastapi.responses import HTMLResponse
710
from pydantic import BaseModel
811

912
from src.instruments.neck_instrument import (
@@ -50,10 +53,13 @@ class NoteInput(BaseModel):
5053
)
5154

5255

53-
@app.get("/")
54-
def read_root() -> dict:
55-
"""Root endpoint for the API."""
56-
return {"message": "Welcome to the Optimal Musical Instrument Fingering API!"}
56+
@app.get("/", response_class=HTMLResponse)
57+
def read_root() -> HTMLResponse:
58+
"""Root endpoint for the API, returns the frontend HTML."""
59+
index_path = Path(__file__).parents[3] / "frontend" / "index.html"
60+
if index_path.exists():
61+
return HTMLResponse(content=index_path.read_text(encoding="utf-8"))
62+
return HTMLResponse(content="<h1>index.html not found</h1>")
5763

5864

5965
@app.get("/getInstrumentDetails")

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies = [
1818
"pretty-midi>=0.2.10",
1919
"pydantic==2.11.7",
2020
"requests==2.32.4",
21+
"setuptools>=80.9",
2122
"uvicorn==0.35",
2223
]
2324
urls.repository = "https://github.com/eliot-christon/optimal-musical-fingering"

0 commit comments

Comments
 (0)