aboutsummaryrefslogtreecommitdiff
path: root/api/dynamic_import.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-03-12 15:24:25 +0100
committerlonkaars <l.leblansch@gmail.com>2021-03-12 15:24:25 +0100
commita69b5df8beddb4a9b492e29ba32747c368666239 (patch)
treee1d0a5b9a6cc9f5e3291759eb74539422a672050 /api/dynamic_import.py
parent3d36847211e37c5aed0a7fdda5c2a00399fdc66e (diff)
friend request api endpoints
Diffstat (limited to 'api/dynamic_import.py')
-rw-r--r--api/dynamic_import.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/api/dynamic_import.py b/api/dynamic_import.py
index 3b05764..76281c2 100644
--- a/api/dynamic_import.py
+++ b/api/dynamic_import.py
@@ -13,10 +13,16 @@ files = [str(filename)
.replace(".py", '')
for filename in files]
+def route(dynamic_route):
+ app.register_blueprint(dynamic_route[1], url_prefix=dynamic_route[0])
+ path = (dynamic_route[0] + "/" + dynamic_route[1].name).replace('//', '/')
+ log.info(f"dynamically routing {path}")
+
for file in files:
mod = importlib.import_module(file)
- if not hasattr(mod, "dynamic_route"): continue
- app.register_blueprint(mod.dynamic_route[1], url_prefix=mod.dynamic_route[0])
- path = (mod.dynamic_route[0] + "/" + mod.dynamic_route[1].name).replace('//', '/')
- log.info(f"dynamically routing {path}")
+ if hasattr(mod, "dynamic_route"):
+ route(mod.dynamic_route)
+ elif hasattr(mod, "dynamic_routes"):
+ for dynamic_route in mod.dynamic_routes:
+ route(dynamic_route)