LoremPizza commited on
Commit
66abf19
·
verified ·
1 Parent(s): eeef32f

Update mediaflow_proxy/main.py

Browse files
Files changed (1) hide show
  1. mediaflow_proxy/main.py +14 -2
mediaflow_proxy/main.py CHANGED
@@ -9,6 +9,9 @@ from starlette.staticfiles import StaticFiles
9
  from mediaflow_proxy.configs import settings
10
  from mediaflow_proxy.routes import proxy_router
11
 
 
 
 
12
  logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
13
  app = FastAPI()
14
  api_password_query = APIKeyQuery(name="api_password", auto_error=False)
@@ -18,11 +21,9 @@ api_password_header = APIKeyHeader(name="api_password", auto_error=False)
18
  async def verify_api_key(api_key: str = Security(api_password_query), api_key_alt: str = Security(api_password_header)):
19
  """
20
  Verifies the API key for the request.
21
-
22
  Args:
23
  api_key (str): The API key to validate.
24
  api_key_alt (str): The alternative API key to validate.
25
-
26
  Raises:
27
  HTTPException: If the API key is invalid.
28
  """
@@ -48,6 +49,17 @@ static_path = resources.files("mediaflow_proxy").joinpath("static")
48
  app.mount("/", StaticFiles(directory=str(static_path), html=True), name="static")
49
 
50
 
 
 
 
 
 
 
 
 
 
 
 
51
  def run():
52
  import uvicorn
53
 
 
9
  from mediaflow_proxy.configs import settings
10
  from mediaflow_proxy.routes import proxy_router
11
 
12
+ import asyncio
13
+ from fastapi import BackgroundTasks
14
+
15
  logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
16
  app = FastAPI()
17
  api_password_query = APIKeyQuery(name="api_password", auto_error=False)
 
21
  async def verify_api_key(api_key: str = Security(api_password_query), api_key_alt: str = Security(api_password_header)):
22
  """
23
  Verifies the API key for the request.
 
24
  Args:
25
  api_key (str): The API key to validate.
26
  api_key_alt (str): The alternative API key to validate.
 
27
  Raises:
28
  HTTPException: If the API key is invalid.
29
  """
 
49
  app.mount("/", StaticFiles(directory=str(static_path), html=True), name="static")
50
 
51
 
52
+ async def print_hello():
53
+ while True:
54
+ print("Hello")
55
+ await asyncio.sleep(5)
56
+
57
+
58
+ @app.on_event("startup")
59
+ async def startup_event():
60
+ asyncio.create_task(print_hello())
61
+
62
+
63
  def run():
64
  import uvicorn
65