Add health check API, logging setup, and environment variable support; update requirements and .gitignore
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from fastapi import APIRouter
|
||||
import logging
|
||||
|
||||
|
||||
#Logging
|
||||
|
||||
logging.basicConfig(
|
||||
filename='api.log', # Log to a file
|
||||
level=logging.DEBUG, # Log everything (DEBUG and above)
|
||||
format='%(asctime)s %(levelname)s %(message)s'
|
||||
)
|
||||
|
||||
logging.info('Application started')
|
||||
try:
|
||||
logging.debug('Debug info here')
|
||||
except Exception as e:
|
||||
logging.exception('An error occurred')
|
||||
|
||||
|
||||
router = APIRouter(prefix="/health", tags=["health"])
|
||||
|
||||
|
||||
@router.get("/")
|
||||
def health_check():
|
||||
logging.info("get health check request")
|
||||
return {"status": "ok"}
|
||||
Reference in New Issue
Block a user