revanced-api/api/__init__.py
2023-11-22 12:33:51 -03:00

17 lines
509 B
Python

# api/__init__.py
from sanic import Blueprint
import importlib
import pkgutil
blueprints = []
for _, module_name, _ in pkgutil.iter_modules(["api"]):
# Import the module
module = importlib.import_module(f"api.{module_name}")
# Add the module's blueprint to the list, if it exists
if hasattr(module, module_name):
blueprints.append(getattr(module, module_name))
# Create the Blueprint group with the dynamically imported blueprints
api = Blueprint.group(*blueprints, url_prefix="/")