Add load_dotenv from dotenv

This commit is contained in:
billz 2024-03-07 18:53:17 +01:00
parent 2365c4e251
commit 75be1bf04e

View file

@ -2,6 +2,9 @@ import os
from fastapi.security.api_key import APIKeyHeader
from fastapi import Security, HTTPException
from starlette.status import HTTP_403_FORBIDDEN
from dotenv import load_dotenv
load_dotenv()
apikey=os.getenv('RASPAP_API_KEY')
#if env not set, set the api key to "insecure"
@ -17,4 +20,5 @@ async def get_api_key(api_key_header: str = Security(api_key_header)):
else:
raise HTTPException(
status_code=HTTP_403_FORBIDDEN, detail="403: Unauthorized"
)
)