Update app.py
Browse files5 unmodified lines67891011121 unmodified line141516171819204 unmodified lines252627282930313233343536371 unmodified line394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571 unmodified line1591601611621631641651661671688 unmodified lines1771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712721 unmodified line2742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113121 unmodified line3143153163173183193203213223233243253263273283293303313323338 unmodified lines34234334434534634734834935035135235335435535635714 unmodified lines3723733743753763773785 unmodified linesapp = Flask(__name__)# ==========================================# FRONTEND: Premium Glassmorphism + Fixed Buttons# ==========================================HTML_TEMPLATE = """<!DOCTYPE html>1 unmodified line<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Twenty IDE | Premium Edition</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><style>:root {4 unmodified lines--text-muted: #888899;--accent: #00f2fe;--radius-big: 24px;--radius-small: 8px; /* Düymələr üçün kənarları biraz daha zərif etdik */}* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }body { background-color: var(--bg-dark); color: var(--text-main); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }/* --- ARXA PLAN NEON İŞIQLARI --- */.ambient-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: #020204; }.orb { position: absolute; border-radius: 50%; filter: blur(150px); opacity: 0.3; }.orb-1 { width: 600px; height: 600px; background: #00f2fe; top: -10%; left: -10%; animation: float 30s infinite alternate ease-in-out; }1 unmodified line@keyframes float { 0% { transform: translate(0, 0); } 100% { transform: translate(20vw, 20vh); } }@keyframes floatReverse { 0% { transform: translate(0, 0); } 100% { transform: translate(-20vw, -20vh); } }/* --- SİRR Lİ VƏ DUMANLI (BLUR) SPLASH EKRANI --- */#splash {position: fixed; inset: 0; background: #020204;z-index: 9999; display: flex; flex-direction: column; justify-content: center; align-items: center;transition: opacity 1.5s ease-in-out;}.splash-text {font-size: 65px; font-weight: 200; color: transparent;margin-left: 30px;animation: breatheMelt 4s cubic-bezier(0.25, 1, 0.5, 1) forwards;}.splash-sub {font-size: 13px; color: var(--accent); letter-spacing: 20px; margin-top: 25px;text-transform: uppercase; margin-left: 20px; opacity: 0;animation: subFade 4s ease-in-out forwards;}@keyframes breatheMelt {0% { opacity: 0; filter: blur(30px); text-shadow: 0 0 0px rgba(0, 242, 254, 0); transform: scale(1.1); letter-spacing: 45px; }40% { opacity: 1; filter: blur(0px); text-shadow: 0 0 60px rgba(0, 242, 254, 0.8); transform: scale(1); letter-spacing: 30px; color: var(--color-white); }70% { opacity: 1; filter: blur(0px); text-shadow: 0 0 40px rgba(0, 242, 254, 0.5); transform: scale(1); letter-spacing: 30px; color: var(--color-white); }100% { opacity: 0; filter: blur(30px); text-shadow: 0 0 0px rgba(0, 242, 254, 0); transform: scale(0.9); letter-spacing: 15px; color: transparent; }}@keyframes subFade {0% { opacity: 0; filter: blur(10px); }40% { opacity: 0.9; filter: blur(0px); }70% { opacity: 0.9; filter: blur(0px); }100% { opacity: 0; filter: blur(15px); }}/* --- ŞÜŞƏ PANEL STİLLƏRİ --- */.glass-panel {background: var(--glass-bg);backdrop-filter: blur(25px);-webkit-backdrop-filter: blur(25px);border: 1px solid var(--glass-border);border-top: 1px solid rgba(255,255,255,0.15);border-radius: var(--radius-big);box-shadow: 0 15px 35px rgba(0,0,0,0.4);overflow: hidden;display: flex; flex-direction: column;}#top-bar { transform: translateY(-50px); opacity: 0; }#sidebar-left { transform: translateX(-50px); opacity: 0; }#center-panel { transform: translateY(50px); opacity: 0; }.anim-top { animation: slideInTop 1s cubic-bezier(0.16, 1, 0.3, 1) forwards; }.anim-left { animation: slideInLeft 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.2s; }.anim-center { animation: slideInUp 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.3s; }@keyframes slideInTop { to { transform: translateY(0); opacity: 1; } }@keyframes slideInLeft { to { transform: translateX(0); opacity: 1; } }@keyframes slideInUp { to { transform: translateY(0); opacity: 1; } }/* --- ÜST PANEL VƏ DÜYMƏLƏR (DÜZƏLDİLDİ) --- */.top-bar {height: 60px; /* Hündürlüyü bir az azaltdıq ki, zərif dursun */margin: 15px 15px 0 15px;display: flex; justify-content: space-between; align-items: center; padding: 0 25px; z-index: 100;}.brand { font-size: 18px; font-weight: 300; letter-spacing: 4px; display: flex; align-items: center; gap: 20px; }.brand i { color: var(--accent); }.controls { display: flex; align-items: center; gap: 20px; /* Düymələr arası məsafəni açdıq */ }.lang-select {background: rgba(0, 0, 0, 0.4); color: var(--text-main); border: 1px solid rgba(255,255,255,0.1);padding: 6px 12px; /* İç boşluğu azaltdıq */border-radius: var(--radius-small); cursor: pointer; outline: none; transition: 0.3s;font-size: 12px; /* Şrifti kiçiltdik */letter-spacing: 1px; font-weight: 500;}.lang-select:hover { border-color: var(--accent); box-shadow: 0 0 10px rgba(0, 242, 254, 0.2); }.run-btn {background: rgba(0, 242, 254, 0.1); color: var(--accent); border: 1px solid var(--accent);padding: 6px 18px; /* İç boşluğu azaltdıq */border-radius: var(--radius-small);cursor: pointer; font-weight: 600; transition: 0.4s; display: flex; align-items: center; gap: 6px;box-shadow: 0 0 15px rgba(0, 242, 254, 0.1); letter-spacing: 1px; font-size: 13px; /* Şrifti kiçiltdik */}.run-btn:hover {background: var(--accent); color: #000;box-shadow: 0 0 20px rgba(0, 242, 254, 0.5);transform: translateY(-2px);}.panel-toggle { background: transparent; color: var(--text-muted); border: none; cursor: pointer; font-size: 18px; transition: 0.3s; padding: 5px; }.panel-toggle:hover { color: white; transform: scale(1.1); }/* --- ƏSAS İŞ ZONASI --- */.main-layout { display: flex; flex: 1; overflow: hidden; padding: 15px; gap: 15px; }.panel-title { padding: 18px 25px; font-size: 11px; text-transform: uppercase; letter-spacing: 3px; color: var(--text-muted); border-bottom: 1px solid var(--glass-border); background: rgba(0,0,0,0.2); }/* Sol Panel */.sidebar-left { width: 300px; transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1); }.sidebar-left.collapsed { width: 0; border: none; margin: 0; opacity: 0; padding: 0; }.file-list { padding: 20px; flex: 1; overflow-y: auto; font-size: 14px; }.folder { margin-bottom: 15px; }.folder-name { color: var(--text-main); display: flex; align-items: center; gap: 10px; margin-bottom: 8px; cursor: pointer; font-weight: 500; opacity: 0.9; }.folder-items { margin-left: 22px; display: flex; flex-direction: column; gap: 5px; border-left: 1px solid rgba(255,255,255,0.1); padding-left: 12px; }.file-item { display: flex; align-items: center; gap: 10px; color: var(--text-muted); cursor: pointer; padding: 10px 12px; border-radius: var(--radius-small); transition: 0.2s; font-size: 13.5px; }.file-item:hover { color: white; background: rgba(255,255,255,0.05); }.file-item.active { color: white; background: rgba(0, 242, 254, 0.1); border-left: 3px solid var(--accent); }/* Orta Panel */.center-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }#editor-container { flex: 1; min-height: 100px; background: rgba(0,0,0,0.2); }/* DRAG RESİZER */.resizer { height: 6px; background: rgba(0,0,0,0.3); cursor: ns-resize; display: flex; justify-content: center; align-items: center; transition: 0.2s; z-index: 50; border-top: 1px solid var(--glass-border); border-bottom: 1px solid var(--glass-border); }.resizer:hover, .resizer:active { background: var(--accent); }.resizer::after { content: ""; width: 40px; height: 3px; background: rgba(255,255,255,0.3); border-radius: 3px; }1 unmodified line/* Terminal */.terminal-wrapper { height: 320px; min-height: 100px; background: rgba(1, 15, 25, 0.5); display: flex; flex-direction: column; }.terminal-header { background: rgba(0,0,0,0.4); padding: 12px 25px; font-size: 12px; color: #999; display: flex; justify-content: space-between; border-bottom: 1px solid var(--glass-border); }#terminal-output {flex: 1; padding: 25px; font-family: 'Consolas', monospace; font-size: 15px;color: #d1d1d1; overflow-y: auto; white-space: pre-wrap; line-height: 1.7; text-align: left;}.ps-prompt { color: var(--accent); font-weight: bold; }.ps-success { color: #c3e88d; }.ps-error { color: #ff5370; }8 unmodified lines</head><body><div class="ambient-bg"><div class="orb orb-1"></div><div class="orb orb-2"></div></div><div id="splash"><div class="splash-text">TWENTY</div><div class="splash-sub">Premium Environment</div></div><div class="glass-panel top-bar" id="top-bar"><div class="brand"><button class="panel-toggle" onclick="togglePanel('left')"><i class="fa-solid fa-folder-tree"></i></button><i class="fa-solid fa-code"></i> TWENTY IDE</div><div class="controls"><select class="lang-select" id="lang-select" onchange="changeLanguage()"><option value="az">AZ</option><option value="en">EN</option></select><button class="run-btn" onclick="runCode()" id="btn-run"><i class="fa-solid fa-play"></i> <span id="t-run">İcra Et</span></button></div></div><div class="main-layout"><div class="glass-panel sidebar-left" id="sidebar-left"><div class="panel-title" id="t-explorer">LAY��HƏ STRUKTURU</div><div class="file-list"><div class="folder"><div class="folder-name"><i class="fa-solid fa-folder-open" style="color:#eac54f;"></i> src</div><div class="folder-items"><div class="file-item active"><i class="fa-brands fa-python" style="color: #ffeb3b;"></i> main.py</div><div class="file-item"><i class="fa-brands fa-python" style="color: #ffeb3b;"></i> utils.py</div></div></div><div class="folder"><div class="folder-name"><i class="fa-solid fa-folder" style="color:#eac54f;"></i> database</div><div class="folder-items"><div class="file-item"><i class="fa-solid fa-database" style="color: #4caf50;"></i> schema.sql</div></div></div><div class="file-item" style="margin-top:15px;"><i class="fa-solid fa-gear" style="color: #aaa;"></i> config.json</div></div></div><div class="glass-panel center-panel" id="center-panel"><div id="editor-container"></div><div class="resizer" id="resizer"></div><div class="terminal-wrapper" id="terminal-wrapper"><div class="terminal-header"><span><i class="fa-solid fa-terminal"></i> PowerShell Engine</span><i class="fa-solid fa-broom" style="cursor:pointer; transition:0.3s;" onclick="clearTerminal()" onmouseover="this.style.color='white'" onmouseout="this.style.color='#999'" title="Təmizlə"></i></div><div id="terminal-output"><span style="color: #888;">// Twenty Premium Engine Aktivdir...</span><span class="ps-prompt">PS C:\\Twenty\\src></span> Hazırdır. Kodunuzu icra edin.</div></div></div></div><script>function changeLanguage() {const lang = document.getElementById('lang-select').value;if(lang === 'az') {document.getElementById('t-run').innerText = 'İcra Et';document.getElementById('t-explorer').innerText = 'LAYİHƏ STRUKTURU';} else {document.getElementById('t-run').innerText = 'Run Code';document.getElementById('t-explorer').innerText = 'PROJECT STRUCTURE';}}// --- KİNO GİRİŞİ (DUMANLI VƏ PARLAYAN) ---window.onload = () => {setTimeout(() => {const splash = document.getElementById('splash');splash.style.opacity = '0';setTimeout(() => {splash.remove();document.getElementById('top-bar').classList.add('anim-top');document.getElementById('sidebar-left').classList.add('anim-left');document.getElementById('center-panel').classList.add('anim-center');}, 1000);}, 4000);};function togglePanel(side) {1 unmodified lineif(editor) setTimeout(() => editor.layout(), 400);}// --- SÜRÜŞDÜRÜCÜ (RESIZER) ---const resizer = document.getElementById('resizer');const terminalWrapper = document.getElementById('terminal-wrapper');let isResizing = false;resizer.addEventListener('mousedown', () => {isResizing = true;document.body.style.cursor = 'ns-resize';});document.addEventListener('mousemove', (e) => {if (!isResizing) return;const containerHeight = document.getElementById('center-panel').clientHeight;const newTerminalHeight = containerHeight - e.clientY + 85;if (newTerminalHeight > 100 && newTerminalHeight < containerHeight - 100) {terminalWrapper.style.height = `${newTerminalHeight}px`;terminalWrapper.style.flex = 'none';if(editor) editor.layout();}});document.addEventListener('mouseup', () => {isResizing = false;document.body.style.cursor = 'default';});// --- MONACO EDITOR ---let editor;require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.36.1/min/vs' }});require(['vs/editor/editor.main'], function() {editor = monaco.editor.create(document.getElementById('editor-container'), {value: "# Twenty IDE: Premium Edition\\n# Dizayn artiq tam olaraq senin isteyinedir.\\n\\nprint('Sisteme Xosh Gelmisiniz!')",language: 'python',theme: 'vs-dark',automaticLayout: true,1 unmodified lineminimap: { enabled: false },padding: { top: 20 }});});async function runCode() {const code = editor.getValue();const terminal = document.getElementById('terminal-output');terminal.innerHTML += `\\n\\n<span class="ps-prompt">PS C:\\\\Twenty\\\\src></span> python main.py\\n<span style="color: #888;">İcra olunur...</span>`;terminal.scrollTop = terminal.scrollHeight;try {const response = await fetch('/run', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ code: code })});const data = await response.json();if (data.status === 'success') {8 unmodified lines}function clearTerminal() {document.getElementById('terminal-output').innerHTML = `<span class="ps-prompt">PS C:\\\\Twenty\\\\src></span> Terminal təmizləndi...`;}</script></body></html>"""# ==========================================# BACKEND: API-lər# ==========================================@app.route('/')def index():return render_template_string(HTML_TEMPLATE)14 unmodified lineselse:return jsonify({"status": "error", "output": result.stderr if result.stderr else result.stdout})except subprocess.TimeoutExpired:return jsonify({"status": "error", "output": "Vaxt bitdi (10 saniyə limit)."})except Exception as e:return jsonify({"status": "error", "output": str(e)})finally:5 unmodified lines67891011121 unmodified line141516171819204 unmodified lines252627282930313233343536371 unmodified line394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051 unmodified line1071081091101111121138 unmodified lines1221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872881 unmodified line2902912922932942952962972982993003013023033043053063073083093103113123133143153163171 unmodified line3193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483498 unmodified lines35835936036136236336436536636736836937014 unmodified lines3853863873883893903915 unmodified linesapp = Flask(__name__)# ==========================================# FRONTEND: Premium Glassmorphism + Live File System# ==========================================HTML_TEMPLATE = """<!DOCTYPE html>1 unmodified line<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Twenty IDE | Live File System</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><style>:root {4 unmodified lines--text-muted: #888899;--accent: #00f2fe;--radius-big: 24px;--radius-small: 8px;}* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }body { background-color: var(--bg-dark); color: var(--text-main); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }/* Arxa Plan İşıqları */.ambient-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: #020204; }.orb { position: absolute; border-radius: 50%; filter: blur(150px); opacity: 0.3; }.orb-1 { width: 600px; height: 600px; background: #00f2fe; top: -10%; left: -10%; animation: float 30s infinite alternate ease-in-out; }1 unmodified line@keyframes float { 0% { transform: translate(0, 0); } 100% { transform: translate(20vw, 20vh); } }@keyframes floatReverse { 0% { transform: translate(0, 0); } 100% { transform: translate(-20vw, -20vh); } }/* Splash Screen */#splash { position: fixed; inset: 0; background: #020204; z-index: 9999; display: flex; flex-direction: column; justify-content: center; align-items: center; transition: opacity 1.5s ease-in-out; }.splash-text { font-size: 65px; font-weight: 200; color: transparent; margin-left: 30px; animation: breatheMelt 3s cubic-bezier(0.25, 1, 0.5, 1) forwards; }.splash-sub { font-size: 13px; color: var(--accent); letter-spacing: 20px; margin-top: 25px; text-transform: uppercase; margin-left: 20px; opacity: 0; animation: subFade 3s ease-in-out forwards; }@keyframes breatheMelt {0% { opacity: 0; filter: blur(30px); text-shadow: 0 0 0px rgba(0, 242, 254, 0); transform: scale(1.1); letter-spacing: 45px; }40% { opacity: 1; filter: blur(0px); text-shadow: 0 0 60px rgba(0, 242, 254, 0.8); transform: scale(1); letter-spacing: 30px; color: var(--color-white); }70% { opacity: 1; filter: blur(0px); text-shadow: 0 0 40px rgba(0, 242, 254, 0.5); transform: scale(1); letter-spacing: 30px; color: var(--color-white); }100% { opacity: 0; filter: blur(30px); text-shadow: 0 0 0px rgba(0, 242, 254, 0); transform: scale(0.9); letter-spacing: 15px; color: transparent; }}@keyframes subFade { 0% { opacity: 0; filter: blur(10px); } 40% { opacity: 0.9; filter: blur(0px); } 70% { opacity: 0.9; filter: blur(0px); } 100% { opacity: 0; filter: blur(15px); } }/* Panellər */.glass-panel { background: var(--glass-bg); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); border: 1px solid var(--glass-border); border-top: 1px solid rgba(255,255,255,0.15); border-radius: var(--radius-big); box-shadow: 0 15px 35px rgba(0,0,0,0.4); overflow: hidden; display: flex; flex-direction: column; }#top-bar { transform: translateY(-50px); opacity: 0; }#sidebar-left { transform: translateX(-50px); opacity: 0; }#center-panel { transform: translateY(50px); opacity: 0; }.anim-top { animation: slideInTop 1s cubic-bezier(0.16, 1, 0.3, 1) forwards; }.anim-left { animation: slideInLeft 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.2s; }.anim-center { animation: slideInUp 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.3s; }@keyframes slideInTop { to { transform: translateY(0); opacity: 1; } }@keyframes slideInLeft { to { transform: translateX(0); opacity: 1; } }@keyframes slideInUp { to { transform: translateY(0); opacity: 1; } }/* Üst Panel */.top-bar { height: 60px; margin: 15px 15px 0 15px; display: flex; justify-content: space-between; align-items: center; padding: 0 25px; z-index: 100; }.brand { font-size: 18px; font-weight: 300; letter-spacing: 4px; display: flex; align-items: center; gap: 20px; }.brand i { color: var(--accent); }.controls { display: flex; align-items: center; gap: 20px; }.lang-select { background: rgba(0, 0, 0, 0.4); color: var(--text-main); border: 1px solid rgba(255,255,255,0.1); padding: 6px 12px; border-radius: var(--radius-small); cursor: pointer; outline: none; transition: 0.3s; font-size: 12px; letter-spacing: 1px; font-weight: 500; }.lang-select:hover { border-color: var(--accent); box-shadow: 0 0 10px rgba(0, 242, 254, 0.2); }.run-btn { background: rgba(0, 242, 254, 0.1); color: var(--accent); border: 1px solid var(--accent); padding: 6px 18px; border-radius: var(--radius-small); cursor: pointer; font-weight: 600; transition: 0.4s; display: flex; align-items: center; gap: 6px; box-shadow: 0 0 15px rgba(0, 242, 254, 0.1); letter-spacing: 1px; font-size: 13px; }.run-btn:hover { background: var(--accent); color: #000; box-shadow: 0 0 20px rgba(0, 242, 254, 0.5); transform: translateY(-2px); }.panel-toggle { background: transparent; color: var(--text-muted); border: none; cursor: pointer; font-size: 18px; transition: 0.3s; padding: 5px; }.panel-toggle:hover { color: white; transform: scale(1.1); }/* Əsas İş Zonası */.main-layout { display: flex; flex: 1; overflow: hidden; padding: 15px; gap: 15px; }/* Sol Panel (Fayl Sistemi) */.sidebar-left { width: 300px; transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1); }.sidebar-left.collapsed { width: 0; border: none; margin: 0; opacity: 0; padding: 0; }.panel-title { padding: 15px 20px; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); border-bottom: 1px solid var(--glass-border); background: rgba(0,0,0,0.2); display: flex; justify-content: space-between; align-items: center; }/* Yeni Fayl Düymələri */.file-actions i { cursor: pointer; margin-left: 10px; font-size: 14px; transition: 0.2s; }.file-actions i:hover { color: var(--accent); transform: scale(1.2); }.file-list { padding: 15px; flex: 1; overflow-y: auto; font-size: 14px; }.file-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text-muted); cursor: pointer; padding: 10px 12px; border-radius: var(--radius-small); transition: 0.2s; font-size: 13.5px; margin-bottom: 5px; }.file-item:hover { color: white; background: rgba(255,255,255,0.05); }.file-item.active { color: white; background: rgba(0, 242, 254, 0.1); border-left: 3px solid var(--accent); }.file-name { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.delete-btn { color: #ff5370; opacity: 0; transition: 0.2s; font-size: 12px; }.file-item:hover .delete-btn { opacity: 0.7; }.delete-btn:hover { opacity: 1 !important; transform: scale(1.1); }/* Orta Panel */.center-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }#editor-container { flex: 1; min-height: 100px; background: rgba(0,0,0,0.2); }.resizer { height: 6px; background: rgba(0,0,0,0.3); cursor: ns-resize; display: flex; justify-content: center; align-items: center; transition: 0.2s; z-index: 50; border-top: 1px solid var(--glass-border); border-bottom: 1px solid var(--glass-border); }.resizer:hover, .resizer:active { background: var(--accent); }.resizer::after { content: ""; width: 40px; height: 3px; background: rgba(255,255,255,0.3); border-radius: 3px; }1 unmodified line/* Terminal */.terminal-wrapper { height: 320px; min-height: 100px; background: rgba(1, 15, 25, 0.5); display: flex; flex-direction: column; }.terminal-header { background: rgba(0,0,0,0.4); padding: 12px 25px; font-size: 12px; color: #999; display: flex; justify-content: space-between; border-bottom: 1px solid var(--glass-border); }#terminal-output { flex: 1; padding: 25px; font-family: 'Consolas', monospace; font-size: 15px; color: #d1d1d1; overflow-y: auto; white-space: pre-wrap; line-height: 1.7; text-align: left; }.ps-prompt { color: var(--accent); font-weight: bold; }.ps-success { color: #c3e88d; }.ps-error { color: #ff5370; }8 unmodified lines</head><body><div class="ambient-bg"><div class="orb orb-1"></div><div class="orb orb-2"></div></div><div id="splash"><div class="splash-text">TWENTY</div><div class="splash-sub">Premium Environment</div></div><div class="glass-panel top-bar" id="top-bar"><div class="brand"><button class="panel-toggle" onclick="togglePanel('left')"><i class="fa-solid fa-folder-tree"></i></button><i class="fa-solid fa-code"></i> <span id="current-filename-display">TWENTY IDE</span></div><div class="controls"><select class="lang-select" id="lang-select"><option value="az">AZ</option><option value="en">EN</option></select><button class="run-btn" onclick="runCode()" id="btn-run"><i class="fa-solid fa-play"></i> İcra Et</button></div></div><div class="main-layout"><div class="glass-panel sidebar-left" id="sidebar-left"><div class="panel-title">LAYİHƏ<div class="file-actions"><i class="fa-solid fa-file-circle-plus" onclick="createNewFile()" title="Yeni Fayl Yarat"></i><i class="fa-solid fa-upload" onclick="document.getElementById('file-upload').click()" title="Kompüterdən Yüklə"></i><input type="file" id="file-upload" style="display: none;" onchange="uploadFile(event)"></div></div><div class="file-list" id="file-tree"></div></div><div class="glass-panel center-panel" id="center-panel"><div id="editor-container"></div><div class="resizer" id="resizer"></div><div class="terminal-wrapper" id="terminal-wrapper"><div class="terminal-header"><span><i class="fa-solid fa-terminal"></i> PowerShell Engine</span><i class="fa-solid fa-broom" style="cursor:pointer; transition:0.3s;" onclick="clearTerminal()" onmouseover="this.style.color='white'" onmouseout="this.style.color='#999'" title="Təmizlə"></i></div><div id="terminal-output"><span style="color: #888;">// Twenty Premium Engine Aktivdir...</span><br><span class="ps-prompt">PS C:\\Twenty></span> Sistem hazırdır.</div></div></div></div><script>// ==========================================// VİRTUAL FAYL SİSTEMİ (VFS) MƏNTİQİ// ==========================================let fileSystem = {"main.py": "# Twenty IDE: Live System\\n\\nprint('Salam, Mühəndis!')\\nprint('Sol tərəfdən yeni fayl yarada bilərsən.')","utils.py": "def hesabla(a, b):\\n return a + b\\n\\n# Bu faylı başqa yerdə çağıra bilərsən"};let currentFile = "main.py";let editor;function renderFileTree() {const tree = document.getElementById('file-tree');tree.innerHTML = "";for (let filename in fileSystem) {// İkon təyinilet icon = '<i class="fa-solid fa-file-code" style="color:#aaa;"></i>';if(filename.endsWith('.py')) icon = '<i class="fa-brands fa-python" style="color:#ffeb3b;"></i>';else if(filename.endsWith('.txt')) icon = '<i class="fa-solid fa-file-lines" style="color:#888;"></i>';const isActive = filename === currentFile ? 'active' : '';// HTML quruluşuconst fileDiv = document.createElement('div');fileDiv.className = `file-item ${isActive}`;fileDiv.innerHTML = `<div class="file-name" onclick="switchFile('${filename}')">${icon} <span>${filename}</span></div><i class="fa-solid fa-trash delete-btn" onclick="deleteFile('${filename}')" title="Sil"></i>`;tree.appendChild(fileDiv);}document.getElementById('current-filename-display').innerText = `TWENTY IDE - ${currentFile}`;}function switchFile(filename) {// Köhnə faylı yadda saxlaif(editor) {fileSystem[currentFile] = editor.getValue();}// Yeni fayla keçcurrentFile = filename;editor.setValue(fileSystem[filename]);// Dili təyin et (Python, txt vs)if(filename.endsWith('.py')) monaco.editor.setModelLanguage(editor.getModel(), "python");else monaco.editor.setModelLanguage(editor.getModel(), "plaintext");renderFileTree();}function createNewFile() {let filename = prompt("Yeni faylın adını yazın (məsələn: test.py):");if(filename && filename.trim() !== "") {if(fileSystem[filename]) {alert("Bu adda fayl artıq var!");return;}fileSystem[filename] = "# Yeni fayl: " + filename;switchFile(filename);}}function deleteFile(filename) {if(Object.keys(fileSystem).length === 1) {alert("Sonuncu faylı silə bilməzsiniz!");return;}if(confirm(`'${filename}' silinsin?`)) {delete fileSystem[filename];if(currentFile === filename) {currentFile = Object.keys(fileSystem)[0]; // İlk tapdığına keçeditor.setValue(fileSystem[currentFile]);}renderFileTree();}}function uploadFile(event) {const file = event.target.files[0];if (!file) return;const reader = new FileReader();reader.onload = function(e) {const content = e.target.result;let filename = file.name;// Eyni adda fayl varsa sonuna rəqəm artırlet counter = 1;while(fileSystem[filename]) {const parts = file.name.split('.');const ext = parts.pop();filename = `${parts.join('.')}_${counter}.${ext}`;counter++;}fileSystem[filename] = content;switchFile(filename);};reader.readAsText(file);event.target.value = ''; // Inputu təmizlə}// --- GİRİŞ ANİMASİYASI ---window.onload = () => {setTimeout(() => {const splash = document.getElementById('splash');splash.style.opacity = '0';setTimeout(() => {splash.remove();document.getElementById('top-bar').classList.add('anim-top');document.getElementById('sidebar-left').classList.add('anim-left');document.getElementById('center-panel').classList.add('anim-center');}, 1000);}, 3000);};function togglePanel(side) {1 unmodified lineif(editor) setTimeout(() => editor.layout(), 400);}// --- SÜRÜŞDÜRÜCÜ ---const resizer = document.getElementById('resizer');const terminalWrapper = document.getElementById('terminal-wrapper');let isResizing = false;resizer.addEventListener('mousedown', () => { isResizing = true; document.body.style.cursor = 'ns-resize'; });document.addEventListener('mousemove', (e) => {if (!isResizing) return;const containerHeight = document.getElementById('center-panel').clientHeight;const newTerminalHeight = containerHeight - e.clientY + 85;if (newTerminalHeight > 100 && newTerminalHeight < containerHeight - 100) {terminalWrapper.style.height = `${newTerminalHeight}px`;terminalWrapper.style.flex = 'none';if(editor) editor.layout();}});document.addEventListener('mouseup', () => { isResizing = false; document.body.style.cursor = 'default'; });// --- MONACO EDITOR ---require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.36.1/min/vs' }});require(['vs/editor/editor.main'], function() {editor = monaco.editor.create(document.getElementById('editor-container'), {value: fileSystem[currentFile],language: 'python',theme: 'vs-dark',automaticLayout: true,1 unmodified lineminimap: { enabled: false },padding: { top: 20 }});// Kodu hər dəyişəndə VFS-də yadda saxlaeditor.onDidChangeModelContent(() => {fileSystem[currentFile] = editor.getValue();});// İlk açılışda fayl ağacını cızrenderFileTree();});// --- TERMINAL İCRA ---async function runCode() {// Əgər dəyişiklik edilibsə son halı yadda saxlafileSystem[currentFile] = editor.getValue();const codeToRun = fileSystem[currentFile];const terminal = document.getElementById('terminal-output');terminal.innerHTML += `\\n\\n<span class="ps-prompt">PS C:\\\\Twenty></span> python ${currentFile}\\n<span style="color: #888;">İcra olunur...</span>`;terminal.scrollTop = terminal.scrollHeight;try {const response = await fetch('/run', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ code: codeToRun })});const data = await response.json();if (data.status === 'success') {8 unmodified lines}function clearTerminal() {document.getElementById('terminal-output').innerHTML = `<span class="ps-prompt">PS C:\\\\Twenty></span> Terminal təmizləndi...`;}</script></body></html>"""@app.route('/')def index():return render_template_string(HTML_TEMPLATE)14 unmodified lineselse:return jsonify({"status": "error", "output": result.stderr if result.stderr else result.stdout})except subprocess.TimeoutExpired:return jsonify({"status": "error", "output": "Vaxt bitdi."})except Exception as e:return jsonify({"status": "error", "output": str(e)})finally:
app.py+171-158