/** * ⚡ ZERO-SETUP IN-BROWSER PYTHON RUNNER (Pyodide / WebAssembly) ⚡ * ================================================================= * Ermöglicht das direkte Ausführen von Python-Code im Browser mit 1 Klick! * Funktioniert mit Pyodide (WebAssembly) oder sicherem lokalem Interpreter. */ (function () { let pyodideInstance = null; let isPyodideLoading = false; async function getPyodide() { if (pyodideInstance) return pyodideInstance; if (isPyodideLoading) { while (isPyodideLoading) { await new Promise(r => setTimeout(r, 100)); } return pyodideInstance; } isPyodideLoading = true; try { if (typeof loadPyodide === "undefined") { // Dynamisch Pyodide-Script laden await new Promise((resolve, reject) => { const script = document.createElement("script"); script.src = "https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.js"; script.onload = resolve; script.onerror = reject; document.head.appendChild(script); }); } pyodideInstance = await loadPyodide({ stdout: (text) => appendOutput(text, "stdout"), stderr: (text) => appendOutput(text, "stderr") }); isPyodideLoading = false; return pyodideInstance; } catch (e) { isPyodideLoading = false; console.warn("Pyodide CDN nicht erreichbar (Offline-Modus aktiv):", e); return null; } } let activeOutputEl = null; function appendOutput(text, type = "stdout") { if (!activeOutputEl) return; const span = document.createElement("div"); span.style.color = type === "stderr" ? "#f87171" : "#a7f3d0"; span.textContent = text; activeOutputEl.appendChild(span); activeOutputEl.scrollTop = activeOutputEl.scrollHeight; } window.initCodeRunnerWidget = function (containerId, initialCode = "") { const container = document.getElementById(containerId); if (!container) return; container.innerHTML = `
Teste deinen Code oder experimentiere mit Beispielen direkt hier im Browser – ohne Terminal!
python3 aufgabe.py!