<!-- examples/web_server_with_processes/views/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Angel3 Process Example</title>
</head>
<body>
    <h1>Run a Process</h1>
    <form id="processForm">
        <label for="command">Command:</label>
        <input type="text" id="command" name="command" required>
        <br>
        <label for="args">Arguments:</label>
        <input type="text" id="args" name="args">
        <br>
        <button type="submit">Run Process</button>
    </form>
    <div id="output"></div>

    <script>
        document.getElementById('processForm').addEventListener('submit', async (e) => {
            e.preventDefault();
            const formData = new FormData(e.target);
            const response = await fetch('/run-process', {
                method: 'POST',
                body: formData
            });
            const result = await response.json();
            document.getElementById('output').innerHTML = `
                <h2>Output:</h2>
                <pre>${result.output}</pre>
                <p>Exit Code: ${result.exitCode}</p>
            `;
        });
    </script>
</body>
</html>
