Spaces:
Running
Running
Rename Dockerfile to index.html
Browse files- Dockerfile +0 -19
- index.html +171 -0
Dockerfile
DELETED
|
@@ -1,19 +0,0 @@
|
|
| 1 |
-
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="utf-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width" />
|
| 6 |
-
<title>My static Space</title>
|
| 7 |
-
<link rel="stylesheet" href="style.css" />
|
| 8 |
-
</head>
|
| 9 |
-
<body>
|
| 10 |
-
<div class="card">
|
| 11 |
-
<h1>Welcome to your static Space!</h1>
|
| 12 |
-
<p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
|
| 13 |
-
<p>
|
| 14 |
-
Also don't forget to check the
|
| 15 |
-
<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
|
| 16 |
-
</p>
|
| 17 |
-
</div>
|
| 18 |
-
</body>
|
| 19 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index.html
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ar" dir="rtl">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>تحليل البيانات والرسم البياني ببايثون</title>
|
| 7 |
+
<!-- مكتبة Pyodide -->
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/pyodide/v0.26.2/full/pyodide.js"></script>
|
| 9 |
+
<style>
|
| 10 |
+
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, sans-serif; }
|
| 11 |
+
body { display: flex; flex-direction: column; height: 100vh; background: #1e1e1e; color: #fff; }
|
| 12 |
+
header { padding: 12px 20px; background: #252526; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #333; }
|
| 13 |
+
header h1 { font-size: 1.1rem; color: #3572A5; }
|
| 14 |
+
.btn-run { background: #007acc; color: white; border: none; padding: 8px 18px; font-weight: bold; cursor: pointer; border-radius: 4px; transition: 0.2s; }
|
| 15 |
+
.btn-run:disabled { background: #555; cursor: not-allowed; }
|
| 16 |
+
.btn-run:hover:not(:disabled) { background: #005999; }
|
| 17 |
+
.container { display: flex; flex: 1; overflow: hidden; }
|
| 18 |
+
.editor, .output { width: 50%; display: flex; flex-direction: column; padding: 10px; gap: 10px; }
|
| 19 |
+
.editor { border-left: 1px solid #333; }
|
| 20 |
+
.output { overflow-y: auto; background: #141414; }
|
| 21 |
+
h3 { font-size: 0.85rem; color: #aaa; text-transform: uppercase; }
|
| 22 |
+
textarea { flex: 1; background: #252526; color: #d4d4d4; border: 1px solid #333; padding: 12px; font-family: 'Consolas', monospace; font-size: 13px; resize: none; outline: none; direction: ltr; text-align: left; line-height: 1.5; }
|
| 23 |
+
pre { background: #000; color: #00ff66; padding: 12px; font-family: 'Consolas', monospace; font-size: 13px; direction: ltr; text-align: left; white-space: pre-wrap; border: 1px solid #333; border-radius: 4px; }
|
| 24 |
+
.plot-container { text-align: center; margin-top: 5px; }
|
| 25 |
+
.plot-container img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid #333; }
|
| 26 |
+
.status { font-size: 0.85rem; color: #e5c07b; margin-left: 15px; }
|
| 27 |
+
@media (max-width: 768px) { .container { flex-direction: column; } .editor, .output { width: 100%; height: 50%; } }
|
| 28 |
+
</style>
|
| 29 |
+
</head>
|
| 30 |
+
<body>
|
| 31 |
+
|
| 32 |
+
<header>
|
| 33 |
+
<h1>📊 تحليلات بايثون (Pandas & Matplotlib)</h1>
|
| 34 |
+
<div>
|
| 35 |
+
<span id="status" class="status">جاري تحميل المحرك والمكتبات...</span>
|
| 36 |
+
<button id="run-btn" class="btn-run" onclick="runPython()" disabled>تشغيل التحليل ▶</button>
|
| 37 |
+
</div>
|
| 38 |
+
</header>
|
| 39 |
+
|
| 40 |
+
<div class="container">
|
| 41 |
+
<!-- قسم المحرر -->
|
| 42 |
+
<div class="editor">
|
| 43 |
+
<h3>كود بايثون</h3>
|
| 44 |
+
<textarea id="code" placeholder="اكتب كود بايثون هنا...">import pandas as pd
|
| 45 |
+
import matplotlib.pyplot as plt
|
| 46 |
+
|
| 47 |
+
# 1. إنشاء جدول بيانات (DataFrame)
|
| 48 |
+
data = {
|
| 49 |
+
'الشهر': ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
|
| 50 |
+
'المبيعات': [1500, 2300, 1800, 3100, 2900],
|
| 51 |
+
'الأرباح': [400, 700, 500, 1100, 950]
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
df = pd.DataFrame(data)
|
| 55 |
+
|
| 56 |
+
# عرض البيانات في الكونسول
|
| 57 |
+
print("--- جدول البيانات ---")
|
| 58 |
+
print(df)
|
| 59 |
+
print("\n--- الإحصائيات الوصفية ---")
|
| 60 |
+
print(df.describe())
|
| 61 |
+
|
| 62 |
+
# 2. إنشاء الرسم البياني
|
| 63 |
+
plt.figure(figsize=(6, 3.5))
|
| 64 |
+
plt.bar(df['الشهر'], df['المبيعات'], color='#3572A5', label='Sales')
|
| 65 |
+
plt.plot(df['الشهر'], df['الأرباح'], color='#ff6b6b', marker='o', linewidth=2, label='Profit')
|
| 66 |
+
|
| 67 |
+
plt.title('Monthly Performance')
|
| 68 |
+
plt.xlabel('Month')
|
| 69 |
+
plt.ylabel('Amount ($)')
|
| 70 |
+
plt.legend()
|
| 71 |
+
plt.grid(axis='y', linestyle='--', alpha=0.3)
|
| 72 |
+
</textarea>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
<!-- قسم المخرجات -->
|
| 76 |
+
<div class="output">
|
| 77 |
+
<h3>المخرجات النصية (Console)</h3>
|
| 78 |
+
<pre id="console">بانتظار تجهيز المكتبات...</pre>
|
| 79 |
+
|
| 80 |
+
<h3>الرسم البياني الناتج</h3>
|
| 81 |
+
<div id="plot-output" class="plot-container">
|
| 82 |
+
<span style="color: #666; font-size: 0.85rem;">سيظهر الرسم البياني هنا بعد التشغيل</span>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<script>
|
| 88 |
+
let pyodide;
|
| 89 |
+
const consoleEl = document.getElementById('console');
|
| 90 |
+
const plotEl = document.getElementById('plot-output');
|
| 91 |
+
const statusEl = document.getElementById('status');
|
| 92 |
+
const runBtn = document.getElementById('run-btn');
|
| 93 |
+
|
| 94 |
+
// تحميل بايثون والمكتبات عند فتح الصفحة
|
| 95 |
+
async function initPyodide() {
|
| 96 |
+
try {
|
| 97 |
+
pyodide = await loadPyodide();
|
| 98 |
+
statusEl.innerText = "جاري تثبيت Pandas & Matplotlib...";
|
| 99 |
+
|
| 100 |
+
// تحميل مكتبات بايثون المطلوبة
|
| 101 |
+
await pyodide.loadPackage(['pandas', 'matplotlib']);
|
| 102 |
+
|
| 103 |
+
statusEl.innerText = "المكتبات جاهزة للعمل!";
|
| 104 |
+
statusEl.style.color = "#98c379";
|
| 105 |
+
consoleEl.innerText = "جاهز لتشغيل التحليل...";
|
| 106 |
+
runBtn.disabled = false;
|
| 107 |
+
} catch (err) {
|
| 108 |
+
statusEl.innerText = "خطأ في تحميل المكتبات";
|
| 109 |
+
consoleEl.innerText = "تفاصيل الخطأ: " + err;
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
// تنفيذ الكود والتقاط النص والرسم البياني
|
| 114 |
+
async function runPython() {
|
| 115 |
+
if (!pyodide) return;
|
| 116 |
+
|
| 117 |
+
runBtn.disabled = true;
|
| 118 |
+
statusEl.innerText = "جاري المعالجة...";
|
| 119 |
+
consoleEl.innerText = "جاري الحسابات...\n";
|
| 120 |
+
plotEl.innerHTML = "";
|
| 121 |
+
|
| 122 |
+
const code = document.getElementById('code').value;
|
| 123 |
+
|
| 124 |
+
// توجيه أومر الطباعة
|
| 125 |
+
pyodide.runPython(`
|
| 126 |
+
import sys
|
| 127 |
+
import io
|
| 128 |
+
sys.stdout = io.StringIO()
|
| 129 |
+
`);
|
| 130 |
+
|
| 131 |
+
try {
|
| 132 |
+
// تنفيذ كود المستخدم
|
| 133 |
+
await pyodide.runPythonAsync(code);
|
| 134 |
+
|
| 135 |
+
// جلب المخرجات النصية
|
| 136 |
+
const stdout = pyodide.runPython("sys.stdout.getvalue()");
|
| 137 |
+
consoleEl.innerText = stdout || "(تم التنفيذ - لا توجد مخرجات نصية)";
|
| 138 |
+
|
| 139 |
+
// استخراج رسم Matplotlib إن وجد وتحويله لـ Base64
|
| 140 |
+
const plotBase64 = pyodide.runPython(`
|
| 141 |
+
import matplotlib.pyplot as plt
|
| 142 |
+
import io, base64
|
| 143 |
+
|
| 144 |
+
img_str = ""
|
| 145 |
+
if plt.get_fignums():
|
| 146 |
+
buf = io.BytesIO()
|
| 147 |
+
plt.savefig(buf, format='png', bbox_inches='tight', dpi=120)
|
| 148 |
+
buf.seek(0)
|
| 149 |
+
img_str = base64.b64encode(buf.read()).decode('utf-8')
|
| 150 |
+
plt.close('all')
|
| 151 |
+
img_str
|
| 152 |
+
`);
|
| 153 |
+
|
| 154 |
+
if (plotBase64) {
|
| 155 |
+
plotEl.innerHTML = `<img src="data:image/png;base64,${plotBase64}" alt="الرسم البياني" />`;
|
| 156 |
+
} else {
|
| 157 |
+
plotEl.innerHTML = `<span style="color: #666; font-size: 0.85rem;">لم يتم إنشاء رسم بياني في هذا الكود.</span>`;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
} catch (err) {
|
| 161 |
+
consoleEl.innerText = "حدث خطأ أثناء التنفيذ:\n" + err;
|
| 162 |
+
} finally {
|
| 163 |
+
runBtn.disabled = false;
|
| 164 |
+
statusEl.innerText = "جاهز!";
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
initPyodide();
|
| 169 |
+
</script>
|
| 170 |
+
</body>
|
| 171 |
+
</html>
|