PythonGradio / app.py
LordXido's picture
Update app.py
5f3038a verified
import os
import zipfile
from pathlib import Path
import gradio as gr
# === CONFIGURATION ===
BUNDLE_ZIP = "Codex_TC2E_Beyond_SOTA_SystemBundle.zip"
EXTRACT_DIR = "CodexReflexSystem"
BOOT_SCRIPT = "main.py" # Ensure this file exists in your bundle
# === UNPACK SYSTEM ONCE ===
def extract_system_bundle():
if not Path(EXTRACT_DIR).exists():
with zipfile.ZipFile(BUNDLE_ZIP, 'r') as zip_ref:
zip_ref.extractall(EXTRACT_DIR)
print(f"[+] Extracted system into: {EXTRACT_DIR}")
else:
print("[i] System already extracted.")
# === RUN SYSTEM ===
def run_codex():
extract_system_bundle()
os.chdir(EXTRACT_DIR)
os.system(f"python {BOOT_SCRIPT}")
# === GRADIO UI WRAPPER ===
def launch_system():
run_codex()
return "Codex Reflex System executed."
iface = gr.Interface(fn=launch_system,
inputs=[],
outputs="text",
title="Codex Reflex Launcher",
description="Click to initialize and execute the CodexReflex system.")
# === ENTRYPOINT ===
if __name__ == "__main__":
extract_system_bundle()
iface.launch(debug=True)