Update app.py
Browse files4 unmodified lines56789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979 unmodified lines1071081091101111121131141151161171181194 unmodified linesapp = Flask(__name__)# ==========================================# TWENTY IDE: SAFE MODE (Direct Start)# ==========================================HTML_TEMPLATE = """<!DOCTYPE html><html lang="az"><head><meta charset="UTF-8"><title>TWENTY IDE | IAHAI</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.23.0/ace.js"></script><style>:root {--bg: #050508;--accent: #00f2fe;--border: rgba(255, 255, 255, 0.1);}body, html { margin: 0; padding: 0; height: 100%; background: var(--bg); color: #fff; font-family: 'Consolas', monospace; overflow: hidden; }/* Arxa Plan */.ambient { position: fixed; inset: 0; z-index: -1; }.orb { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.1; }.orb-1 { width: 400px; height: 400px; background: var(--accent); top: -100px; left: -100px; }.wrapper { display: grid; grid-template-columns: 60px 240px 1fr 280px; height: 100vh; }/* Panellər */.sidebar, .activity-bar, .ai-panel { background: rgba(10, 10, 15, 0.8); border-right: 1px solid var(--border); }.activity-bar { display: flex; flex-direction: column; align-items: center; padding: 20px 0; gap: 25px; }.sidebar { padding: 20px; }.main-editor { display: flex; flex-direction: column; background: rgba(15, 15, 20, 0.4); }.header { height: 50px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }#editor { flex: 1; font-size: 15px !important; }.terminal { height: 200px; background: #000; border-top: 1px solid var(--border); padding: 15px; overflow-y: auto; color: #00ffaa; font-size: 14px; }.run-btn { background: var(--accent); color: #000; border: none; padding: 8px 20px; border-radius: 4px; cursor: pointer; font-weight: bold; }</style></head><body><div class="ambient"><div class="orb orb-1"></div></div><div class="wrapper"><div class="activity-bar"><i class="fa-solid fa-file-code" style="color:var(--accent)"></i><i class="fa-solid fa-gear"></i></div><div class="sidebar"><h4 style="font-size:12px; color:#555;">EXPLORER</h4><div style="margin-top:15px; font-size:14px; color:var(--accent);"><i class="fa-brands fa-python"></i> main.py</div></div><div class="main-editor"><div class="header"><span style="font-size:12px; opacity:0.6;">main.py</span><button class="run-btn" onclick="runCode()">RUN</button></div><div id="editor">print("TWENTY IDE işləyir!")# Kodunuzu bura yazın</div><div class="terminal" id="output">Terminal hazır...</div></div><div class="ai-panel" style="padding:20px;"><h4 style="font-size:12px; color:var(--accent);">EXYPOS AI</h4><p style="font-size:12px; color:#666; margin-top:10px;">Hazıram, qardaş!</p></div></div><script>// Ace Editor-u birbaşa işə salırıqvar editor = ace.edit("editor");editor.setTheme("ace/theme/tomorrow_night_eighties");editor.session.setMode("ace/mode/python");editor.setOptions({ showPrintMargin: false, fontSize: "15px" });async function runCode() {const code = editor.getValue();const out = document.getElementById('output');out.innerText = "İcra olunur...";try {const res = await fetch('/run', {method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify({code: code})});const data = await res.json();out.innerText = data.output;} catch (e) {out.innerText = "Xəta: Serverlə bağlantı kəsildi.";}}</script>9 unmodified linesdef run_code():code = request.json.get('code', '')try:with open('temp.py', 'w', encoding='utf-8') as f:f.write(code)result = subprocess.run(['python3', 'temp.py'], capture_output=True, text=True, timeout=10)output = result.stdout if not result.stderr else result.stderrreturn jsonify({'output': output})except Exception as e:return jsonify({'output': str(e)})if __name__ == "__main__":app.run(host="0.0.0.0", port=7860)4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091109 unmodified lines1201211221231241251261271281291301311321331341354 unmodified linesapp = Flask(__name__)# ==========================================# TWENTY IDE: CORE FOCUS (Direct Interface)# ==========================================HTML_TEMPLATE = """<!DOCTYPE html><html lang="az"><head><meta charset="UTF-8"><title>TWENTY IDE | IAHAI Core</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.23.0/ace.js"></script><style>:root {--bg: #0b0b0e;--accent: #00f2fe;--border: rgba(255, 255, 255, 0.1);--panel: #111116;}* { box-sizing: border-box; margin: 0; padding: 0; }body, html { height: 100%; background: var(--bg); color: #e0e0e0; font-family: 'Consolas', monospace; overflow: hidden; }.wrapper { display: grid; grid-template-columns: 50px 220px 1fr 280px; height: 100vh; }/* Sol Panellər */.activity-bar { background: #08080a; border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 20px 0; gap: 25px; }.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 15px; }/* Redaktor Sahəsi */.main-content { display: flex; flex-direction: column; background: #141419; }.editor-header { height: 45px; background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 15px; }#editor { flex: 1; font-size: 15px !important; }/* Terminal */.terminal { height: 220px; background: #000; border-top: 1px solid var(--border); padding: 15px; overflow-y: auto; color: #00ffaa; font-family: 'Courier New', monospace; }/* AI Paneli */.ai-panel { background: var(--panel); border-left: 1px solid var(--border); padding: 20px; }.run-btn { background: var(--accent); color: #000; border: none; padding: 6px 15px; border-radius: 3px; cursor: pointer; font-weight: bold; font-size: 12px; }.run-btn:hover { box-shadow: 0 0 10px var(--accent); opacity: 0.9; }</style></head><body><div class="wrapper"><div class="activity-bar"><i class="fa-solid fa-code" style="color:var(--accent)"></i><i class="fa-solid fa-robot" style="color:#555"></i><i class="fa-solid fa-gear" style="color:#555"></i></div><aside class="sidebar"><h4 style="font-size:11px; color:#555; letter-spacing:1px;">EXPLORER</h4><div style="margin-top:15px; font-size:13px; color:var(--accent);"><i class="fa-brands fa-python"></i> main.py</div></aside><main class="main-content"><div class="editor-header"><span style="font-size:11px; color:#888;">main.py</span><button class="run-btn" onclick="runCode()"><i class="fa-solid fa-play"></i> RUN</button></div><div id="editor"># TWENTY IDE | IAHAI# Python kodunu bura yazın və RUN düyməsini sıxın.def test():print("TWENTY 'Beyni' uğurla işə düşdü!")print(f"Nəticə: {10 + 10}")test()</div><div class="terminal" id="output">Terminal hazır...</div></main><aside class="ai-panel"><h4 style="font-size:11px; color:var(--accent); letter-spacing:1px;">EXYPOS AI</h4><div id="ai-status" style="margin-top:20px; font-size:12px; line-height:1.5; color:#888;">Sən yaz, mən burdayam. Kodunu yoxlamağa hazıram!</div></aside></div><script>var editor = ace.edit("editor");editor.setTheme("ace/theme/tomorrow_night_eighties");editor.session.setMode("ace/mode/python");editor.setOptions({ showPrintMargin: false, fontSize: "15px", wrap: true });async function runCode() {const code = editor.getValue();const outputElement = document.getElementById('output');outputElement.innerText = "> Script işə düşür...\\n";outputElement.style.color = "#00ffaa";try {const response = await fetch('/run', {method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify({code: code})});const data = await response.json();outputElement.innerText = data.output;if(data.error) outputElement.style.color = "#ff4444";} catch (err) {outputElement.innerText = "Xəta: Backend ilə əlaqə qurula bilmədi.";outputElement.style.color = "#ff4444";}}</script>9 unmodified linesdef run_code():code = request.json.get('code', '')try:# Kodun icrasıwith open('temp_run.py', 'w', encoding='utf-8') as f:f.write(code)result = subprocess.run(['python3', 'temp_run.py'], capture_output=True, text=True, timeout=10)output = result.stdout if not result.stderr else result.stderrreturn jsonify({'output': output, 'error': bool(result.stderr)})except Exception as e:return jsonify({'output': f"Sistem Xətası: {str(e)}", 'error': True})if __name__ == "__main__":app.run(host="0.0.0.0", port=7860)
app.py+65-49