def get_routes(package):
routes = []
for _, modname, ispkg in pkgutil.walk_packages(
path=package.__path__,
prefix=package.__name__ + '.',
onerror=lambda x: None):
if not ispkg:
module = import_module(modname)
for k, cls in vars(module).items():
if k.startswith("_") or not isinstance(cls, six.class_types):
continue
if issubclass(cls, BaseAPI):
if getattr(cls, "route", False):
routes.append(cls)
return routes
# monkeypatch to force application json on raised exceptions
评论列表
文章目录