Skip to content

Commit

Permalink
fix directory
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebou12 committed Sep 23, 2023
1 parent 72cb524 commit 17ce309
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('..')
Expand All @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 17ce309

Please sign in to comment.