IGNORE_MODULES = ['__init__']
folder = os.path.dirname(os.path.abspath(__file__))
target = folder.replace('routes', 'resource')
modules = os.listdir(target)
resource_list = get_module_resource_list(modules, IGNORE_MODULES)
for module, resource_name in resource_list:
resource_class = getattr(module, resource_name)
try:
url = getattr(resource_class, 'url')
except AttributeError:
# the path will be not work as not setting url
continue
api.add_resource(resource_class, url)