File size: 863 Bytes
29cdc9d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import os
class IntegrationEngine:
def __init__(self, project_root="src/devcore/sandbox/project_build"):
self.entry_point = os.path.join(project_root, "app.py")
def wire(self, module_name, function_name):
# We need to make sure the app.py exists before we append
if not os.path.exists(self.entry_point):
with open(self.entry_point, "w") as f:
f.write("from flask import Flask\napp = Flask(__name__)\n")
with open(self.entry_point, "a") as f:
f.write(f"\n\n# Dynamic Integration: {module_name}")
f.write(f"\nfrom app.{module_name} import {function_name}")
f.write(f"\napp.add_url_rule('/{module_name}', '{module_name}', {function_name}, methods=['POST'])")
print(f"[+] INTEGRATED: '{module_name}' is now live at /api/{module_name}")
|