forked from Devasy23/FaceRec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (25 loc) · 940 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from __future__ import annotations
import logging
from concurrent.futures import ThreadPoolExecutor
from API import run_fastapi_app
from FaceRec.app.main import run_flask
# Initialize logging configuration
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Function to run Flask app with exception handling
def run_flask_app():
try:
run_flask()
except Exception as e:
logger.error(f"Error starting Flask app: {e}")
# Function to run FastAPI app with exception handling
def run_fastapi_app_with_handling():
try:
run_fastapi_app()
except Exception as e:
logger.error(f"Error starting FastAPI app: {e}")
# Multithreading used to start both FastAPI and Flask apps at the same time.
if __name__ == "__main__":
with ThreadPoolExecutor(max_workers=2) as executor:
executor.submit(run_flask_app)
executor.submit(run_fastapi_app_with_handling)