OpenBlox chat

import sys
import os
import subprocess
import webview  # pip install pywebview

class OpenBloxAPI:
    """Functions here map directly to your website's JavaScript window context."""
    
    def run_python_code(self, code_text):
        print("\n--- [Executing Local Python Script] ---")
        try:
            runtime_file = os.path.abspath("runtime_exec.py")
            with open(runtime_file, "w", encoding="utf-8") as f:
                f.write(code_text)
                
            # Spawns your 3D Ursina modules or engines safely
            subprocess.Popen([sys.executable, runtime_file])
            return "Launched successfully"
        except Exception as e:
            return f"Error: {str(e)}"

    def run_pip_install(self, command_text):
        print(f"\n--- [Running System Pip Command]: {command_text} ---")
        try:
            subprocess.run(command_text, shell=True)
            return "Installation complete"
        except Exception as e:
            return str(e)

if __name__ == "__main__":
    api_bridge = OpenBloxAPI()
    
    # Create the window pointing straight to your website url
    window = webview.create_window(
        title="OpenBlox Client App Launcher",
        url="https://openblox.neocities.org/fullgamelol.html",
        js_api=api_bridge,
        width=1300,
        height=850
    )
    
    webview.start(debug=True)