               } else if (result.image) {
                    outputDiv.innerHTML = `<img src="data:image/png;base64,${result.image}" />`;
                } else {
                    outputDiv.innerHTML = `<div class="output-text">${escapeHtml(result.result || '')}</div>`;
                }
            } else {
                outputDiv.innerHTML = `<div class="error-output"><div class="traceback">${escapeHtml(result.error || result.result || 'Unknown error')}</div></div>`;
            }
        }
        