diff --git a/api/app.py b/api/app.py index 09e7cfe..405519c 100644 --- a/api/app.py +++ b/api/app.py @@ -3,6 +3,7 @@ from fastapi.responses import HTMLResponse from fastapi.templating import Jinja2Templates from fastapi.security import HTTPBasic, HTTPBasicCredentials +import os # import sys # sys.path.append('..') @@ -11,7 +12,8 @@ # Initialize FastAPI and Jinja2 app = FastAPI(docs_url="/docs", redoc_url=None) -templates=Jinja2Templates(directory="templates") +# smae directory +templates=Jinja2Templates(directory=os.path.join(current_directory, "templates")) app.add_middleware( CORSMiddleware, @@ -32,6 +34,10 @@ async def get_current_user(credentials: HTTPBasicCredentials = Depends(security) # Log the error here if you want raise HTTPException(status_code=401, detail="MarketWatch validation failed") +@app.get("/") +def read_root(request: Request): + return "Marketwatch API" + @app.get("/game/{game_id}", response_class=HTMLResponse) async def game(request: Request, game_id: str, mw: MarketWatch = Depends(get_current_user)): data = mw.get_game(game_id=game_id)