mirror of
https://github.com/sunrin-ana/2025-SSF.git
synced 2026-03-09 18:40:02 +00:00
2025 SSF Public
This commit is contained in:
commit
76a02076c9
192 changed files with 5016 additions and 0 deletions
21
Backend/router/router.py
Normal file
21
Backend/router/router.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import os
|
||||
import traceback
|
||||
from fastapi import APIRouter
|
||||
from fastapi.logger import logger
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
for router_file in os.listdir("Backend/router/endpoints"):
|
||||
try:
|
||||
if router_file.endswith(".py"):
|
||||
module_name = "Backend.router.endpoints." + router_file[:-3]
|
||||
module = __import__(module_name, fromlist=[""])
|
||||
router_object = getattr(module, "router")
|
||||
prefix = getattr(module, "prefix", router_file[:-3])
|
||||
|
||||
router.include_router(router_object, prefix="/api", tags=[router_file[:-3]])
|
||||
print(f"Loaded router: /api/{prefix} - {router_file}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading router {router_file}:\n{traceback.format_exc()}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue