Update app.py
Browse files15 unmodified lines161718191920212222232524252627282930323132333435383637383940414245434445495051525354555657585960616263646566676869707172737475767778798046474849505152535455565758828384855960616287888990919293949563979864656667686970717273747576777879808182102103104105106107108109110111112113114115116117118119120121122123124125126127838485868788899012913013113291929394959697981341351361371389910010110210310414010510614210710810911011111211311411511611711811912012114414512212312412512612712812913013113213313414714814915015115215315415515615715815916016116216316416516616716816917013517213613713813914014114214314414517918018118218318418518618714614714814915019119215115215315419515515615715815916020120220320420520620720820921021116121316221521621721821922022116316416516622516716816922822923023123223323423523623723823924024124224324417017117217317417517617717824925017918018125218218318425525618518618718825918919019126319219319419519619719827027119920020120220327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231320420520620720831631731831932032120921021121221321421521621721821922022132322222322432632732832933033133233333433533633733833934034134234334434534634734834922522622722822923023135135235335435535635735835936036136236336436523223336836937037137237323423523623723823924024124237737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444524324424524644824724845045124925025145325225325445625525645845946046125725825926026146346426226326446726526646947026726826927027127247227327427527627747747847948048148248348448548648748848927827928028128228328428528628728828929029129229329429529629729829930030130230349149230430530630749449549649749849950050150250350450530830931031150750831231331431531631731831932032132232332432532632732832933033133233333433533633733851051133934034134234334434534634734834935051851935135235335452352452552652752852953053153253353453553653753853954054154254354435535635735835954654754854955055155255355455555655736036136236336436536656156256356456556656756856957036736836937057257337137237357557657757857958037437537637758258358437837938038158738215 unmodified lines<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Twenty IDE | Ultimate Liquid</title> <title>Twenty IDE | Final Workspace</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> /* CSS Dəyişənləri (Gecə/Gündüz Modu üçün) */ :root { --bg-base: #050505; --bg-panel: rgba(15, 15, 20, 0.6); --bg-panel: rgba(15, 15, 20, 0.7); --border-color: rgba(255, 255, 255, 0.1); --text-main: #f4f4f5; --text-muted: #888899; --accent: #00f2fe; --liquid-1: #00f2fe; --liquid-2: #4facfe; --editor-bg: rgba(0,0,0,0.4); --radius: 12px; }
.light-mode { --bg-base: #f0f2f5; --bg-panel: rgba(255, 255, 255, 0.7); --bg-panel: rgba(255, 255, 255, 0.8); --border-color: rgba(0, 0, 0, 0.1); --text-main: #111827; --text-muted: #6b7280; --accent: #0284c7; --liquid-1: #bae6fd; --liquid-2: #e0f2fe; --editor-bg: rgba(255,255,255,0.5); }
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; } body { background-color: var(--bg-base); color: var(--text-main); height: 100vh; display: flex; flex-direction: column; overflow: hidden; transition: background 0.5s; }
/* LIQUID (MAYE) ARXA PLAN ANİMASİYASI */ .liquid-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg-base); transition: 0.5s; } .shape { position: absolute; filter: blur(60px); opacity: 0.4; animation: liquidMorph 15s ease-in-out infinite alternate; } .shape-1 { width: 50vw; height: 50vw; background: var(--liquid-1); top: -10%; left: -10%; border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; } .shape-2 { width: 45vw; height: 45vw; background: var(--liquid-2); bottom: -10%; right: -10%; border-radius: 60% 40% 30% 70% / 50% 60% 40% 50%; animation-delay: -5s; } @keyframes liquidMorph { 0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; transform: rotate(0deg) scale(1); } 100% { border-radius: 60% 40% 30% 70% / 50% 60% 40% 50%; transform: rotate(45deg) scale(1.1); } }
/* --- 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; }
body { background-color: var(--bg-base); color: var(--text-main); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
/* LIQUID ARXA PLAN */ .liquid-bg { position: fixed; inset: 0; z-index: -1; background: var(--bg-base); } .shape { position: absolute; filter: blur(70px); opacity: 0.35; animation: liquidMorph 15s ease-in-out infinite alternate; } .shape-1 { width: 50vw; height: 50vw; background: var(--liquid-1); top: -10%; left: -10%; border-radius: 40% 60%; } .shape-2 { width: 45vw; height: 45vw; background: var(--liquid-2); bottom: -10%; right: -10%; border-radius: 60% 40%; animation-delay: -5s; } @keyframes liquidMorph { 0% { transform: translate(0,0) rotate(0deg); } 100% { transform: translate(10vw, 10vh) rotate(90deg); } }
/* 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.2s ease-in-out; } .splash-text { font-size: 65px; font-weight: 200; color: transparent; letter-spacing: 30px; animation: breatheMelt 3.5s 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: #fff; } 70% { opacity: 1; filter: blur(0px); text-shadow: 0 0 40px rgba(0, 242, 254, 0.5); transform: scale(1); letter-spacing: 30px; color: #fff; } 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; } 0% { opacity: 0; filter: blur(20px); text-shadow: 0 0 0px #00f2fe; transform: scale(1.1); } 50% { opacity: 1; filter: blur(0px); text-shadow: 0 0 40px #00f2fe; transform: scale(1); color: #fff; } 100% { opacity: 0; filter: blur(20px); transform: scale(0.9); } } @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-glass { background: var(--bg-panel); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,0.2); transition: 0.3s; }
/* Üst Panel */ .top-bar { height: 60px; margin: 10px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; z-index: 100; opacity: 0; transform: translateY(-50px); animation: slideInTop 1s cubic-bezier(0.16, 1, 0.3, 1) forwards 3.5s; } /* ANİMASİYA BAŞLANĞICI (GİZLİ) */ .panel-glass { background: var(--bg-panel); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px); border: 1px solid var(--border-color); border-radius: var(--radius); transition: 0.5s cubic-bezier(0.16, 1, 0.3, 1); } #top-bar { transform: translateY(-100px); opacity: 0; } #sidebar-left { transform: translateX(-300px); opacity: 0; } #center-panel { transform: translateY(300px); opacity: 0; } #sidebar-right { transform: translateX(400px); opacity: 0; }
/* ANİMASİYA AKTİV (SÜRÜŞMƏ) */ .show-ui #top-bar { transform: translateY(0); opacity: 1; } .show-ui #sidebar-left { transform: translateX(0); opacity: 1; transition-delay: 0.2s; } .show-ui #center-panel { transform: translateY(0); opacity: 1; transition-delay: 0.4s; } .show-ui #sidebar-right { transform: translateX(0); opacity: 1; transition-delay: 0.6s; }
/* ÜST PANEL */ .top-bar { height: 60px; margin: 10px; display: flex; justify-content: space-between; align-items: center; padding: 0 25px; z-index: 100; } .brand { font-size: 16px; font-weight: 500; letter-spacing: 2px; display: flex; align-items: center; gap: 15px; } .brand i { color: var(--accent); } .controls { display: flex; align-items: center; gap: 15px; } .btn { background: rgba(0,0,0,0.2); color: var(--text-main); border: 1px solid var(--border-color); padding: 8px 15px; border-radius: 6px; cursor: pointer; transition: 0.2s; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px;} .light-mode .btn { background: rgba(255,255,255,0.5); } .btn:hover { border-color: var(--accent); color: var(--accent); } .btn-run { background: rgba(0, 242, 254, 0.1); border-color: var(--accent); color: var(--accent); } .btn-run:hover { background: var(--accent); color: #fff; transform: translateY(-2px); }
@keyframes slideInTop { to { transform: translateY(0); opacity: 1; } }
/* Ayarlar Modalı */ #settings-modal { display: none; position: fixed; top: 75px; right: 20px; width: 250px; z-index: 200; padding: 20px; flex-direction: column; gap: 15px; } .setting-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; } select, input { background: transparent; color: var(--text-main); border: 1px solid var(--border-color); padding: 5px; border-radius: 4px; outline: none; } .light-mode select option { background: #fff; color: #000; } .light-mode select { background: #fff; }
/* Əsas Layout */ .main-layout { display: flex; flex: 1; overflow: hidden; padding: 0 10px 10px 10px; gap: 10px; opacity: 0; animation: fadeIn 1s forwards 3.8s; } @keyframes fadeIn { to { opacity: 1; } } /* Sol Panel (Advanced VFS) */ .sidebar-left { width: 260px; display: flex; flex-direction: column; transition: 0.3s; } .sidebar-left.collapsed { width: 0; opacity: 0; margin: 0; border: none; } .panel-header { padding: 15px; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; } .file-actions i { cursor: pointer; transition: 0.2s; margin-left: 8px; font-size: 14px; } .file-actions i:hover { color: var(--accent); } .file-tree { flex: 1; overflow-y: auto; padding: 10px; font-size: 13.5px; } .btn { background: rgba(255,255,255,0.05); color: var(--text-main); border: 1px solid var(--border-color); padding: 8px 16px; border-radius: 8px; cursor: pointer; transition: 0.2s; font-size: 13px; display: flex; align-items: center; gap: 8px; } .btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(0, 242, 254, 0.1); } .btn-run { background: var(--accent); color: #000; border: none; font-weight: 700; } .btn-run:hover { background: #fff; color: #000; transform: translateY(-2px); box-shadow: 0 0 20px var(--accent); }
/* LAYOUT */ .main-layout { display: flex; flex: 1; overflow: hidden; padding: 0 10px 10px 10px; gap: 10px; } .folder-item { margin-bottom: 5px; cursor: pointer; user-select: none; } .folder-title { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 4px; color: var(--text-main); font-weight: 500;} .folder-title:hover { background: rgba(128,128,128,0.1); } .folder-content { margin-left: 15px; padding-left: 10px; border-left: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 2px; margin-top: 5px;} /* SIDEBARS */ .sidebar-left { width: 260px; display: flex; flex-direction: column; overflow: hidden; } .sidebar-left.collapsed { width: 0; border: none; padding: 0; margin: 0; } .sidebar-right { width: 340px; display: flex; flex-direction: column; overflow: hidden; } .sidebar-right.collapsed { width: 0; border: none; padding: 0; margin: 0; }
.panel-header { padding: 15px; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.1); } .file-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-radius: 4px; cursor: pointer; color: var(--text-muted); transition: 0.2s; } .file-item:hover { color: var(--text-main); background: rgba(128,128,128,0.1); } .file-item.active { background: rgba(0, 242, 254, 0.1); color: var(--text-main); border-left: 2px solid var(--accent); } .del-btn { opacity: 0; color: #f87171; transition: 0.2s; } .file-item:hover .del-btn { opacity: 1; } /* VFS TREE */ .file-tree { flex: 1; overflow-y: auto; padding: 10px; font-size: 13.5px; } .file-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 6px; cursor: pointer; margin-bottom: 2px; transition: 0.2s; color: var(--text-muted); } .file-item:hover { background: rgba(255,255,255,0.05); color: #fff; } .file-item.active { background: rgba(0, 242, 254, 0.1); color: var(--accent); border-left: 3px solid var(--accent); }
/* Orta Panel */ /* EDITOR */ .center-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; } #editor-container { flex: 1; min-height: 100px; background: var(--editor-bg); border-radius: var(--radius) var(--radius) 0 0; } #editor-container { flex: 1; background: rgba(0,0,0,0.3); }
/* TERMINAL */ .bottom-panel { height: 260px; display: flex; flex-direction: column; background: var(--bg-panel); } .tabs { display: flex; background: rgba(0,0,0,0.3); border-bottom: 1px solid var(--border-color); } .tab { padding: 10px 20px; font-size: 12px; cursor: pointer; color: var(--text-muted); border-right: 1px solid var(--border-color); } .tab.active { color: var(--accent); background: rgba(0, 242, 254, 0.05); border-bottom: 2px solid var(--accent); } #terminal-output { flex: 1; padding: 15px; font-family: 'Consolas', monospace; font-size: 14px; overflow-y: auto; color: #ccc; }
/* AI CHAT & CODE BLOCKS */ #ai-chat { flex: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; } .msg { padding: 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; position: relative; } .msg.user { background: rgba(0, 242, 254, 0.1); align-self: flex-end; border: 1px solid var(--accent); } .msg.ai { background: rgba(255,255,255,0.05); align-self: flex-start; border: 1px solid var(--border-color); } .resizer { height: 6px; cursor: ns-resize; background: transparent; transition: 0.2s; z-index: 50; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); } .resizer:hover { background: var(--accent); } /* AI KOD BLOKU */ .ai-code-block { background: #0d0d0d; border-radius: 8px; margin-top: 10px; border: 1px solid #333; overflow: hidden; } .ai-code-header { padding: 5px 10px; background: #1a1a1a; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #333; } .ai-code-header span { font-size: 10px; color: #888; text-transform: uppercase; } .copy-to-editor { background: var(--accent); color: #000; border: none; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; cursor: pointer; } .ai-code-block pre { padding: 12px; font-family: 'Consolas', monospace; font-size: 12px; color: #dcdcaa; overflow-x: auto; margin: 0; }
/* Alt Panel */ .bottom-panel { height: 280px; min-height: 100px; display: flex; flex-direction: column; background: var(--bg-panel); border-radius: 0 0 var(--radius) var(--radius); } .bottom-tabs { display: flex; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.2); } .tab { padding: 10px 20px; font-size: 12px; cursor: pointer; color: var(--text-muted); transition: 0.2s; border-right: 1px solid var(--border-color); } .tab.active { color: var(--accent); background: transparent; border-bottom: 2px solid var(--accent); } .tab-content { flex: 1; overflow: hidden; display: none; } .tab-content.active { display: flex; flex-direction: column; } #terminal-output { flex: 1; padding: 15px; font-family: 'Consolas', monospace; font-size: 14px; color: #d1d1d1; overflow-y: auto; white-space: pre-wrap; line-height: 1.6; } .light-mode #terminal-output { color: #333; } .ps-cmd { color: var(--accent); font-weight: bold; } .ps-err { color: #f87171; } .ps-ok { color: #4ade80; }
#browser-frame { flex: 1; border: none; width: 100%; height: 100%; background: #fff; }
/* Sağ Panel (Exypos AI) */ .sidebar-right { width: 320px; display: flex; flex-direction: column; transition: 0.3s; } .sidebar-right.collapsed { width: 0; opacity: 0; margin: 0; border: none; } #ai-chat { flex: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; font-size: 13.5px; } .msg { padding: 10px 15px; border-radius: 8px; max-width: 90%; line-height: 1.5; } .msg.user { background: rgba(0, 242, 254, 0.1); border: 1px solid var(--accent); align-self: flex-end; } .msg.ai { background: rgba(128, 128, 128, 0.1); border: 1px solid var(--border-color); align-self: flex-start; } .ai-input-zone { padding: 15px; border-top: 1px solid var(--border-color); display: flex; gap: 10px; } .ai-input-zone input { flex: 1; background: transparent; border: 1px solid var(--border-color); color: var(--text-main); padding: 8px; border-radius: 4px; outline: none; } .ai-input-zone input { flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); color: #fff; padding: 10px; border-radius: 8px; outline: none; }
.resizer { height: 6px; cursor: ns-resize; border-top: 1px solid var(--border-color); } .resizer:hover { background: var(--accent); }
</style> <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.36.1/min/vs/loader.min.js"></script></head><body>
<div class="liquid-bg"> <div class="shape shape-1"></div> <div class="shape shape-2"></div> </div>
<div id="splash"> <div class="splash-text">TWENTY</div> <div class="splash-sub">Premium Environment</div> </div> <div class="liquid-bg"><div class="shape shape-1"></div><div class="shape shape-2"></div></div> <div id="splash"><div class="splash-text">TWENTY</div></div>
<div class="panel-glass top-bar" id="top-bar"> <div class="brand"> <button class="icon-btn" onclick="togglePanel('left')" style="background:transparent; border:none; color:var(--text-muted); cursor:pointer;"><i class="fa-solid fa-folder-tree"></i></button> <i class="fa-solid fa-code"></i> TWENTY IDE <span style="color:var(--text-muted); font-size:12px;">| <span id="current-file-label">main.py</span></span> <button class="btn" onclick="togglePanel('left')"><i class="fa-solid fa-folder-tree"></i></button> <i class="fa-solid fa-code"></i> TWENTY IDE <span id="file-label" style="color:var(--text-muted); font-size:12px; margin-left:10px;">/ main.py</span> </div> <div class="controls"> <button class="btn" onclick="toggleSettings()"><i class="fa-solid fa-gear"></i> Ayarlar</button> <button class="btn" onclick="toggleTheme()"><i class="fa-solid fa-circle-half-stroke"></i></button> <button class="btn" onclick="togglePanel('right')"><i class="fa-solid fa-robot"></i> Exypos AI</button> <button class="btn btn-run" onclick="runCode()"><i class="fa-solid fa-play"></i> İcra Et</button> </div> </div>
<div class="panel-glass" id="settings-modal"> <div class="panel-header" style="padding:0 0 10px 0;">Sistem Ayarları</div> <div class="setting-row"> Mövzu: <select id="theme-select" onchange="changeTheme()"> <option value="dark">Tünd (Gece)</option> <option value="light">Açıq (Gündüz)</option> </select> </div> </div>
<div class="main-layout"> <div class="panel-glass sidebar-left" id="sidebar-left"> <div class="panel-header"> Fayl Sistemi <div class="file-actions"> <i class="fa-solid fa-folder-plus" onclick="createFolder()" title="Qovluq Yarat"></i> <i class="fa-solid fa-file-circle-plus" onclick="createFile()" title="Fayl Yarat"></i> </div> </div> <div class="panel-header">FAYL SİSTEMİ <i class="fa-solid fa-file-circle-plus" onclick="createFile()" style="cursor:pointer"></i></div> <div class="file-tree" id="file-tree"></div> </div>
<div class="panel-glass center-panel"> <div class="center-panel" id="center-panel"> <div id="editor-container"></div> <div class="resizer" id="resizer"></div> <div class="bottom-panel" id="bottom-panel"> <div class="bottom-tabs"> <div class="tab active" onclick="switchTab('terminal')"><i class="fa-solid fa-terminal"></i> Terminal / Console</div> <div class="tab" onclick="switchTab('browser')"><i class="fa-brands fa-chrome"></i> Browser Preview</div> <i class="fa-solid fa-broom" style="margin-left:auto; margin-right:15px; margin-top:8px; cursor:pointer; color:var(--text-muted);" onclick="clearTerminal()" title="Təmizlə"></i> </div> <div class="tab-content active" id="tab-terminal"> <div id="terminal-output"><span style="color:#888;">// Twenty Engine Başladı...</span><span style="color:#888;">// Məsləhət: Konsol komandası (pip install, ls) üçün kodun əvvəlinə ! qoyub İcra Et basın.</span><br> </div> </div> <div class="tab-content" id="tab-browser"> <iframe id="browser-frame"></iframe> <div class="panel-glass bottom-panel"> <div class="tabs"> <div class="tab active">TERMINAL</div> <div class="tab" onclick="clearTerminal()">TƏMİZLƏ</div> </div> <div id="terminal-output">// Twenty Engine Hazırdır...<br>PS C:\\Twenty> </div> </div> </div>
<div class="panel-glass sidebar-right collapsed" id="sidebar-right"> <div class="panel-header">EXYPOS AI Köməkçi</div> <div class="panel-glass sidebar-right" id="sidebar-right"> <div class="panel-header">EXYPOS AI</div> <div id="ai-chat"> <div class="msg ai">Salam! Mən Exypos. Sənə kod yazmaqda necə kömək edə bilərəm?</div> <div class="msg ai">Salam! Mən Exypos. Sənə necə kömək edə bilərəm?</div> </div> <div class="ai-input-zone"> <input type="text" id="ai-input" placeholder="Sualını yaz..." onkeypress="if(event.key === 'Enter') askAI()"> <button onclick="askAI()" style="background:transparent; border:none; cursor:pointer;"><i class="fa-solid fa-paper-plane" style="color:var(--accent); font-size:16px;"></i></button> <input type="text" id="ai-input" placeholder="Sualını yaz..." onkeypress="if(event.key==='Enter') askAI()"> <button class="btn" onclick="askAI()"><i class="fa-solid fa-paper-plane"></i></button> </div> </div>
</div>
<script> // --- GİRİŞ ANİMASİYASI ZAMANLAMASI --- // --- ANİMASİYA GİRİŞİ --- window.onload = () => { setTimeout(() => { const splash = document.getElementById('splash'); splash.style.opacity = '0'; setTimeout(() => { splash.remove(); }, 1000); }, 3800); document.body.classList.add('show-ui'); }, 1200); }, 3500); };
// --- AYARLAR & MÖVZU --- function toggleSettings() { const modal = document.getElementById('settings-modal'); modal.style.display = modal.style.display === 'flex' ? 'none' : 'flex'; } function changeTheme() { const isLight = document.getElementById('theme-select').value === 'light'; if(isLight) { document.body.classList.add('light-mode'); if(editor) monaco.editor.setTheme('vs-light'); } else { document.body.classList.remove('light-mode'); if(editor) monaco.editor.setTheme('vs-dark'); } }
function togglePanel(side) { document.getElementById(`sidebar-${side}`).classList.toggle('collapsed'); if(editor) setTimeout(() => editor.layout(), 300); }
// --- BOTTOM TABS (Terminal vs Browser) --- function switchTab(tabId) { document.querySelectorAll('.tab').forEach(t => t.classList.remove('active')); document.querySelectorAll('.tab-content').forEach(tc => tc.classList.remove('active')); event.currentTarget.classList.add('active'); document.getElementById(`tab-${tabId}`).classList.add('active'); }
// --- VİRTUAL FAYL SİSTEMİ --- let vfs = { "root": { "main.py": "# Python kodunuz\\n\\nprint('Salam Twenty IDE!')\\n\\n# Qeyd: Terminal komandası üçün ! istifadə edin.\\n# Məsələn: !pip install requests", "Web": { "index.html": "<!DOCTYPE html>\\n<html>\\n<head><style>body{background:#222;color:#fff;font-family:sans-serif;text-align:center;padding:50px;}</style></head>\\n<body>\\n <h1>Twenty Veb Server</h1>\\n <p>Browser tabında dərhal işləyir!</p>\\n</body>\\n</html>" } } }; let currentFilePath = ["root", "main.py"]; // --- VFS & EDITOR --- let vfs = { "main.py": "print('Salam Twenty IDE!')\\n# Exypos AI-dan kod isteyin!" }; let currentFile = "main.py"; let editor;
function getFileIcon(name) { if(name.endsWith('.py')) return '<i class="fa-brands fa-python" style="color:#ffeb3b;"></i>'; if(name.endsWith('.html')) return '<i class="fa-brands fa-html5" style="color:#e34f26;"></i>'; if(name.endsWith('.js')) return '<i class="fa-brands fa-js" style="color:#f7df1e;"></i>'; return '<i class="fa-solid fa-file-code" style="color:#aaa;"></i>'; } 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: vfs[currentFile], language: 'python', theme: 'vs-dark', automaticLayout: true, fontSize: 15, padding: { top: 20 } }); renderFiles(); });
function renderVFS() { function renderFiles() { const tree = document.getElementById('file-tree'); tree.innerHTML = ""; for(let folderName in vfs) { const folderDiv = document.createElement('div'); folderDiv.className = 'folder-item'; folderDiv.innerHTML = `<div class="folder-title"><i class="fa-solid fa-folder-open" style="color:#eac54f;"></i> ${folderName}</div>`; const contentDiv = document.createElement('div'); contentDiv.className = 'folder-content'; for(let fileName in vfs[folderName]) { const isActive = (currentFilePath[0] === folderName && currentFilePath[1] === fileName) ? 'active' : ''; const fileDiv = document.createElement('div'); fileDiv.className = `file-item ${isActive}`; fileDiv.innerHTML = ` <div style="display:flex; align-items:center; gap:8px;" onclick="openFile('${folderName}', '${fileName}')"> ${getFileIcon(fileName)} <span>${fileName}</span> </div> <i class="fa-solid fa-trash del-btn" onclick="deleteFile('${folderName}', '${fileName}', event)"></i> `; contentDiv.appendChild(fileDiv); } folderDiv.appendChild(contentDiv); tree.appendChild(folderDiv); for(let f in vfs) { const div = document.createElement('div'); div.className = `file-item ${f === currentFile ? 'active' : ''}`; div.innerHTML = `<span><i class="fa-brands fa-python"></i> ${f}</span><i class="fa-solid fa-trash" onclick="deleteFile('${f}')" style="font-size:10px"></i>`; div.onclick = () => switchFile(f); tree.appendChild(div); } document.getElementById('current-file-label').innerText = currentFilePath[1]; }
function openFile(folder, file) { if(editor) vfs[currentFilePath[0]][currentFilePath[1]] = editor.getValue(); currentFilePath = [folder, file]; editor.setValue(vfs[folder][file]); let lang = "plaintext"; if(file.endsWith('.py')) lang = "python"; else if(file.endsWith('.html')) lang = "html"; else if(file.endsWith('.js')) lang = "javascript"; monaco.editor.setModelLanguage(editor.getModel(), lang); renderVFS(); }
function createFolder() { const name = prompt("Yeni qovluq adı:"); if(name && !vfs[name]) { vfs[name] = {}; renderVFS(); } function switchFile(f) { vfs[currentFile] = editor.getValue(); currentFile = f; editor.setValue(vfs[f]); document.getElementById('file-label').innerText = "/ " + f; renderFiles(); }
function createFile() { const folder = prompt("Hansı qovluğa? Mövcud: " + Object.keys(vfs).join(', '), "root"); if(folder && vfs[folder]) { const name = prompt("Faylın adı (məs: test.py):"); if(name && !vfs[folder][name]) { vfs[folder][name] = "# " + name; openFile(folder, name); } } }
function deleteFile(folder, file, event) { event.stopPropagation(); if(confirm(`${file} silinsin?`)) { delete vfs[folder][file]; if(currentFilePath[0] === folder && currentFilePath[1] === file) { const fallbackFolder = Object.keys(vfs)[0]; const fallbackFile = Object.keys(vfs[fallbackFolder])[0]; if(fallbackFile) openFile(fallbackFolder, fallbackFile); else editor.setValue(""); } renderVFS(); } }
// --- İCRA SİSTEMİ --- async function runCode() { if(!editor) return; vfs[currentFilePath[0]][currentFilePath[1]] = editor.getValue(); const code = editor.getValue(); const filename = currentFilePath[1]; if(filename.endsWith('.html')) { document.querySelectorAll('.tab')[1].click(); // Browser tabını aç const frame = document.getElementById('browser-frame'); frame.srcdoc = code; return; }
document.querySelectorAll('.tab')[0].click(); // Terminal tabını aç const term = document.getElementById('terminal-output'); const isShell = code.trim().startsWith('!'); if(isShell) { term.innerHTML += `<br><span class="ps-cmd">Twenty Shell></span> ${code.trim()}<br><span style="color:#888">Terminal komandası icra olunur (Zaman ala bilər)...</span>`; } else { term.innerHTML += `<br><span class="ps-cmd">PS C:\\Twenty></span> python ${filename}<br><span style="color:#888">İcra olunur...</span>`; } term.scrollTop = term.scrollHeight; try { const response = await fetch('/run', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ code: code, is_shell: isShell }) }); const data = await response.json(); if (data.status === 'success') { term.innerHTML += `<br><span class="ps-ok">${data.output}</span>`; } else { term.innerHTML += `<br><span class="ps-err">${data.output}</span>`; } } catch (error) { term.innerHTML += `<br><span class="ps-err">Bağlantı xətası!</span>`; } term.scrollTop = term.scrollHeight; }
function clearTerminal() { document.getElementById('terminal-output').innerHTML = `<span class="ps-cmd">Twenty></span> Konsol təmizləndi...`; const name = prompt("Fayl adı:"); if(name && !vfs[name]) { vfs[name] = "# " + name; switchFile(name); } }
// --- EXYPOS AI --- // --- EXYPOS AI & KOD ENJEKSİYASI --- async function askAI() { const inputEl = document.getElementById('ai-input'); const prompt = inputEl.value.trim(); const input = document.getElementById('ai-input'); const prompt = input.value.trim(); if(!prompt) return;
const chat = document.getElementById('ai-chat'); chat.innerHTML += `<div class="msg user">${prompt}</div>`; inputEl.value = ''; input.value = ""; chat.scrollTop = chat.scrollHeight; const typingId = "type-" + Date.now(); chat.innerHTML += `<div class="msg ai" id="${typingId}">...</div>`;
const typingId = "ai-" + Date.now(); chat.innerHTML += `<div class="msg ai" id="${typingId}">Düşünürəm...</div>`;
try { const contextCode = editor ? editor.getValue() : ""; const response = await fetch('/ask_ai', { const res = await fetch('/ask_ai', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ prompt: prompt, code: contextCode }) body: JSON.stringify({ prompt: prompt, code: editor.getValue() }) }); const data = await response.json(); document.getElementById(typingId).innerHTML = data.reply.replace(/\\n/g, '<br>'); const data = await res.json(); // Kodu və mətni ayırırıq const processedReply = formatAIReply(data.reply); document.getElementById(typingId).innerHTML = processedReply; } catch (e) { document.getElementById(typingId).innerHTML = "<span style='color:red'>AI Bağlantı xətası.</span>"; document.getElementById(typingId).innerText = "Xəta baş verdi."; } chat.scrollTop = chat.scrollHeight; }
// --- SÜRÜŞDÜRÜCÜ --- const resizer = document.getElementById('resizer'); const bottomPanel = document.getElementById('bottom-panel'); let isResizing = false; resizer.addEventListener('mousedown', () => { isResizing = true; document.body.style.cursor = 'ns-resize'; }); document.addEventListener('mousemove', (e) => { if (!isResizing) return; const containerHeight = document.querySelector('.center-panel').clientHeight; const newHeight = containerHeight - e.clientY + 50; if (newHeight > 100 && newHeight < containerHeight - 100) { bottomPanel.style.height = `${newHeight}px`; bottomPanel.style.flex = 'none'; if(editor) editor.layout(); function formatAIReply(text) { // Markdown kod bloklarını tapırıq (```python ... ```) const codeRegex = /```(?:python|py)?\\n([\\s\\S]*?)```/g; let lastIndex = 0; let html = ""; let match;
while ((match = codeRegex.exec(text)) !== null) { // Koddan əvvəlki mətni əlavə et html += text.substring(lastIndex, match.index).replace(/\\n/g, "<br>"); const code = match[1].trim(); const escapedCode = code.replace(/"/g, '"').replace(/'/g, "\\'");
// Kod blokunu düymə ilə birgə əlavə et html += ` <div class="ai-code-block"> <div class="ai-code-header"> <span>Python Code</span> <button class="copy-to-editor" onclick="injectToEditor(\`${escapedCode}\`)">Editora At</button> </div> <pre><code>${code}</code></pre> </div> `; lastIndex = match.index + match[0].length; } }); document.addEventListener('mouseup', () => { isResizing = false; document.body.style.cursor = 'default'; }); html += text.substring(lastIndex).replace(/\\n/g, "<br>"); return html; }
// --- MONACO EDITOR İNİT --- 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: vfs[currentFilePath[0]][currentFilePath[1]], language: 'python', theme: 'vs-dark', automaticLayout: true, fontSize: 15, minimap: { enabled: false }, padding: { top: 15 } }); function injectToEditor(code) { const selection = editor.getSelection(); const range = new monaco.Range(selection.startLineNumber, selection.startColumn, selection.endLineNumber, selection.endColumn); editor.onDidChangeModelContent(() => { vfs[currentFilePath[0]][currentFilePath[1]] = editor.getValue(); // Kodu seçili yerə və ya kursor olan yerə qüsursuz yapışdırır editor.executeEdits("beautifier", [{ range: range, text: code, forceMoveMarkers: true }]); // AI panelini bağlaya bilərik (istəyə bağlı) // togglePanel('right'); }
// --- DİGƏR FUNKSİYALAR --- function togglePanel(id) { document.getElementById(`sidebar-${id}`).classList.toggle('collapsed'); setTimeout(() => editor.layout(), 300); }
function toggleTheme() { document.body.classList.toggle('light-mode'); }
async function runCode() { const term = document.getElementById('terminal-output'); term.innerHTML += `<br><span style="color:var(--accent)">> python ${currentFile}</span><br>`; const res = await fetch('/run', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ code: editor.getValue() }) }); renderVFS(); }); const data = await res.json(); term.innerHTML += data.output.replace(/\\n/g, "<br>"); term.scrollTop = term.scrollHeight; }
function clearTerminal() { document.getElementById('terminal-output').innerHTML = "PS C:\\\\Twenty> "; } </script></body></html>"""
@app.route('/')def index(): return render_template_string(HTML_TEMPLATE)def index(): return render_template_string(HTML_TEMPLATE)
@app.route('/run', methods=['POST'])def run_code(): data = request.json code = data.get('code', '') is_shell = data.get('is_shell', False) if not code.strip(): return jsonify({"status": "error", "output": "Boş kod göndərildi."}) if is_shell: shell_cmd = code.strip()[1:] try: result = subprocess.run(shell_cmd, shell=True, capture_output=True, text=True, timeout=30) output = result.stdout if result.returncode == 0 else result.stderr status = "success" if result.returncode == 0 else "error" return jsonify({"status": status, "output": output}) except subprocess.TimeoutExpired: return jsonify({"status": "error", "output": "Vaxt bitdi (30 saniyə limit)."}) except Exception as e: return jsonify({"status": "error", "output": str(e)})
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False, encoding='utf-8') as temp_file: temp_file.write(code) temp_filepath = temp_file.name code = request.json.get('code', '') with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f: f.write(code) path = f.name try: result = subprocess.run(['python', temp_filepath], capture_output=True, text=True, timeout=10) if result.returncode == 0: return jsonify({"status": "success", "output": result.stdout}) else: 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: if os.path.exists(temp_filepath): os.remove(temp_filepath) res = subprocess.run(['python', path], capture_output=True, text=True, timeout=10) return jsonify({"output": res.stdout if res.returncode == 0 else res.stderr}) except: return jsonify({"output": "Vaxt bitdi."}) finally: os.remove(path)
@app.route('/ask_ai', methods=['POST'])def ask_ai(): if not client_groq: return jsonify({"reply": "Xəta: Groq API Key (GROQ_API_KEY) tapılmadı."}) data = request.json prompt = data.get('prompt', '') context_code = data.get('code', '') system_msg = "Sən Exypos AI-san. Twenty IDE-nin köməkçisisən. Qısa, dəqiq və azərbaycanca cavab ver." user_msg = f"Sual: {prompt}\\n\\nHazırki kodum:\\n```\\n{context_code}\\n```" if not client_groq: return jsonify({"reply": "API Key yoxdur."}) prompt = request.json.get('prompt') code = request.json.get('code') try: # XƏTA BURADA İDİ: Model yeniləndi! chat_completion = client_groq.chat.completions.create( completion = client_groq.chat.completions.create( model="llama-3.1-8b-instant", messages=[ {"role": "system", "content": system_msg}, {"role": "user", "content": user_msg} ], model="llama-3.1-8b-instant", temperature=0.5, max_tokens=1000 {"role": "system", "content": "Sən Exypos AI-san. Kodları MÜTLƏQ ```python ... ``` blokunda ver. Python boşluqlarına (4 boşluq) ciddi əməl et."}, {"role": "user", "content": f"Hazırkı kod:\\n{code}\\n\\nSual: {prompt}"} ] ) return jsonify({"reply": chat_completion.choices[0].message.content}) except Exception as e: return jsonify({"reply": f"AI Xətası: {str(e)}"}) return jsonify({"reply": completion.choices[0].message.content}) except Exception as e: return jsonify({"reply": str(e)})
if __name__ == "__main__": app.run(host="0.0.0.0", port=7860, debug=False) app.run(host="0.0.0.0", port=7860)app.py+235-440