37 lines
820 B
Python
37 lines
820 B
Python
import logging
|
|
import threading
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from chain_service.logging import setup_logging
|
|
from chain_service.controllers.__main__ import setup_controllers
|
|
|
|
setup_logging()
|
|
|
|
application = FastAPI()
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
|
|
# Subclass threading.Thread for logging
|
|
class DebugThread(threading.Thread):
|
|
def __init__(self, *args, **kwargs):
|
|
logging.debug(f"Creating thread {args} {kwargs}")
|
|
super().__init__(*args, **kwargs)
|
|
|
|
def _delete(self):
|
|
logging.debug(f"Deleting thread {self.name}")
|
|
super()._delete()
|
|
|
|
|
|
threading.Thread = DebugThread
|
|
|
|
application.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:5173"],
|
|
allow_methods=["*"],
|
|
)
|
|
|
|
setup_controllers(application)
|