قم بانشاء كود بايثون يعمل وصط صفحه ويب
Browse files- README.md +8 -5
- index.html +126 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: DarkPythonPlayground 🐍
|
| 3 |
+
colorFrom: yellow
|
| 4 |
+
colorTo: blue
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
index.html
CHANGED
|
@@ -1,19 +1,127 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en" class="dark">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Python Code Runner</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 9 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js"></script>
|
| 11 |
+
<style>
|
| 12 |
+
.cm-editor {
|
| 13 |
+
height: 100% !important;
|
| 14 |
+
font-size: 14px !important;
|
| 15 |
+
}
|
| 16 |
+
.cm-scroller {
|
| 17 |
+
font-family: 'Fira Code', monospace !important;
|
| 18 |
+
}
|
| 19 |
+
.cm-gutters {
|
| 20 |
+
background-color: #111827 !important;
|
| 21 |
+
border-right: 1px solid #374151 !important;
|
| 22 |
+
}
|
| 23 |
+
.cm-activeLineGutter {
|
| 24 |
+
background-color: #1f2937 !important;
|
| 25 |
+
}
|
| 26 |
+
.cm-content {
|
| 27 |
+
caret-color: white !important;
|
| 28 |
+
}
|
| 29 |
+
</style>
|
| 30 |
+
</head>
|
| 31 |
+
<body class="bg-gray-900 text-gray-100 min-h-screen flex flex-col">
|
| 32 |
+
<header class="bg-black border-b border-gray-800 py-4 px-6">
|
| 33 |
+
<div class="flex items-center justify-between">
|
| 34 |
+
<div class="flex items-center space-x-2">
|
| 35 |
+
<i data-feather="code" class="text-green-500"></i>
|
| 36 |
+
<h1 class="text-xl font-bold">DarkPythonPlayground</h1>
|
| 37 |
+
</div>
|
| 38 |
+
<div class="flex items-center space-x-4">
|
| 39 |
+
<button id="run-btn" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-md flex items-center space-x-2 transition duration-200">
|
| 40 |
+
<i data-feather="play" class="w-4 h-4"></i>
|
| 41 |
+
<span>Run</span>
|
| 42 |
+
</button>
|
| 43 |
+
<button id="theme-toggle" class="p-2 rounded-md hover:bg-gray-800 transition duration-200">
|
| 44 |
+
<i data-feather="moon" class="w-5 h-5"></i>
|
| 45 |
+
</button>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
</header>
|
| 49 |
+
|
| 50 |
+
<main class="flex-1 flex flex-col md:flex-row overflow-hidden">
|
| 51 |
+
<div class="flex-1 border-r border-gray-800 overflow-hidden">
|
| 52 |
+
<div id="editor" class="h-full w-full"></div>
|
| 53 |
+
</div>
|
| 54 |
+
<div class="flex-1 flex flex-col overflow-hidden">
|
| 55 |
+
<div class="border-b border-gray-800 py-2 px-4 flex items-center">
|
| 56 |
+
<i data-feather="terminal" class="text-green-500 mr-2"></i>
|
| 57 |
+
<h2 class="font-medium">Output</h2>
|
| 58 |
+
</div>
|
| 59 |
+
<div id="output" class="flex-1 overflow-auto p-4 font-mono text-sm bg-gray-800"></div>
|
| 60 |
+
</div>
|
| 61 |
+
</main>
|
| 62 |
+
|
| 63 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/codemirror.min.js"></script>
|
| 64 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/mode/python/python.min.js"></script>
|
| 65 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/edit/matchbrackets.min.js"></script>
|
| 66 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/addon/edit/closebrackets.min.js"></script>
|
| 67 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/6.65.7/theme/dracula.min.js"></script>
|
| 68 |
+
<script>
|
| 69 |
+
feather.replace();
|
| 70 |
+
|
| 71 |
+
let pyodide;
|
| 72 |
+
async function initializePyodide() {
|
| 73 |
+
pyodide = await loadPyodide({
|
| 74 |
+
indexURL: "https://cdn.jsdelivr.net/pyodide/v0.23.4/full/"
|
| 75 |
+
});
|
| 76 |
+
await pyodide.loadPackage("micropip");
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
const editor = CodeMirror(document.getElementById('editor'), {
|
| 80 |
+
mode: 'python',
|
| 81 |
+
lineNumbers: true,
|
| 82 |
+
theme: 'dracula',
|
| 83 |
+
autoCloseBrackets: true,
|
| 84 |
+
matchBrackets: true,
|
| 85 |
+
indentUnit: 4,
|
| 86 |
+
tabSize: 4,
|
| 87 |
+
value: `# Welcome to DarkPythonPlayground!\n# Write your Python code here and click Run\n\ndef greet(name):\n return f"Hello, {name}!"\n\nprint(greet("Python Developer"))`
|
| 88 |
+
});
|
| 89 |
+
|
| 90 |
+
document.getElementById('run-btn').addEventListener('click', async () => {
|
| 91 |
+
if (!pyodide) {
|
| 92 |
+
await initializePyodide();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
const code = editor.getValue();
|
| 96 |
+
const outputDiv = document.getElementById('output');
|
| 97 |
+
outputDiv.innerHTML = '<span class="text-gray-400">Running...</span>';
|
| 98 |
+
|
| 99 |
+
try {
|
| 100 |
+
const result = await pyodide.runPythonAsync(code);
|
| 101 |
+
if (result !== undefined) {
|
| 102 |
+
outputDiv.innerHTML = `<span class="text-green-400">${result}</span>`;
|
| 103 |
+
} else {
|
| 104 |
+
outputDiv.innerHTML = '<span class="text-green-400">Code executed successfully!</span>';
|
| 105 |
+
}
|
| 106 |
+
} catch (error) {
|
| 107 |
+
outputDiv.innerHTML = `<span class="text-red-400">${error}</span>`;
|
| 108 |
+
}
|
| 109 |
+
});
|
| 110 |
+
|
| 111 |
+
// Theme toggle
|
| 112 |
+
const themeToggle = document.getElementById('theme-toggle');
|
| 113 |
+
themeToggle.addEventListener('click', () => {
|
| 114 |
+
const html = document.documentElement;
|
| 115 |
+
if (html.classList.contains('dark')) {
|
| 116 |
+
html.classList.remove('dark');
|
| 117 |
+
themeToggle.innerHTML = '<i data-feather="sun" class="w-5 h-5"></i>';
|
| 118 |
+
feather.replace();
|
| 119 |
+
} else {
|
| 120 |
+
html.classList.add('dark');
|
| 121 |
+
themeToggle.innerHTML = '<i data-feather="moon" class="w-5 h-5"></i>';
|
| 122 |
+
feather.replace();
|
| 123 |
+
}
|
| 124 |
+
});
|
| 125 |
+
</script>
|
| 126 |
+
</body>
|
| 127 |
</html>
|