Skip to content

Commit

Permalink
Feat : 쓰레드 테스트 및 로그 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hu-nie committed Apr 7, 2024
1 parent 513bd7a commit d478289
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from fastapi import FastAPI
from routers import stats
import uvicorn
import logging

logging.basicConfig(filename='/var/log/app.log', level=logging.INFO)
app = FastAPI()


Expand Down
9 changes: 6 additions & 3 deletions backend/app/routers/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
from fastapi.responses import JSONResponse
from basketball_reference_web_scraper import client
from basketball_reference_web_scraper.data import OutputType

import threading
import logging

router = APIRouter(
prefix="/stats",
tags=["stats"]
)

@router.get('/')
async def welcome():
def welcome():
"""
API 가동 상태 확인 엔드포인트.
"""
Expand All @@ -32,7 +33,9 @@ def player_stats(date: date = Query(...), name: Optional[str] = None):
stats = stats_scraper.specific_player_stats(name)
else:
stats = stats_scraper.daily_player_stats()

thread_id = threading.get_ident() # 현재 스레드 ID를 가져옵니다
logging.info(f"Handling request in thread {thread_id}") # 로깅

return JSONResponse(content=stats)

@router.get('/team_stats/')
Expand Down

0 comments on commit d478289

Please sign in to comment.