Spaces:
Running
Running
File size: 9,115 Bytes
b81acae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Python Tool - Toolbox Haven</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
.code-editor {
font-family: 'Fira Code', monospace;
background-color: #1e293b;
border-radius: 0.5rem;
}
.output-panel {
background-color: #1e1e2e;
border-radius: 0.5rem;
}
.tab-active {
border-bottom: 2px solid #3b82f6;
color: #3b82f6;
}
</style>
</head>
<body class="bg-gray-900 text-gray-100">
<div class="container mx-auto px-4 py-8">
<!-- Tool Header -->
<header class="flex justify-between items-center mb-8">
<div class="flex items-center space-x-3">
<a href="index.html" class="text-gray-400 hover:text-white transition">
<i data-feather="arrow-left" class="w-5 h-5"></i>
</a>
<div class="flex items-center space-x-2">
<div class="bg-blue-500 bg-opacity-20 p-2 rounded-lg">
<i data-feather="code" class="w-5 h-5 text-blue-400"></i>
</div>
<h1 class="text-2xl font-bold">Python Code Tool</h1>
</div>
</div>
<div class="flex space-x-3">
<button class="bg-gray-800 hover:bg-gray-700 px-4 py-2 rounded-lg flex items-center space-x-2 transition">
<i data-feather="save" class="w-4 h-4"></i>
<span>Save</span>
</button>
<button class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg flex items-center space-x-2 transition">
<i data-feather="play" class="w-4 h-4"></i>
<span>Run</span>
</button>
</div>
</header>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- Code Editor -->
<div class="lg:col-span-1">
<div class="bg-gray-800 rounded-xl p-4 h-full flex flex-col">
<div class="flex border-b border-gray-700 mb-4">
<button class="tab-active pb-2 px-4 font-medium">main.py</button>
<button class="text-gray-400 pb-2 px-4 font-medium hover:text-white transition">utils.py</button>
<button class="text-gray-400 pb-2 px-4 font-medium hover:text-white transition">config.py</button>
<button class="ml-auto text-gray-400 hover:text-white transition">
<i data-feather="plus" class="w-5 h-5"></i>
</button>
</div>
<div class="code-editor flex-grow p-4 overflow-auto">
<pre class="text-sm"><code class="text-gray-300"># Python Code Analyzer Tool
# Enter your Python code below
def analyze_code(code):
"""Analyze Python code for complexity and style"""
import ast
from collections import defaultdict
tree = ast.parse(code)
stats = defaultdict(int)
for node in ast.walk(tree):
stats[type(node).__name__] += 1
return dict(stats)
def main():
sample_code = '''
def factorial(n):
if n == 0:
return 1
return n * factorial(n-1)
'''
results = analyze_code(sample_code)
print("Code Analysis Results:")
for k, v in results.items():
print(f"{k}: {v}")
if __name__ == "__main__":
main()</code></pre>
</div>
</div>
</div>
<!-- Output Panel -->
<div class="lg:col-span-1">
<div class="bg-gray-800 rounded-xl p-4 h-full flex flex-col">
<div class="flex items-center justify-between border-b border-gray-700 pb-3 mb-4">
<h3 class="font-bold">Output</h3>
<div class="flex space-x-2">
<button class="text-gray-400 hover:text-white transition">
<i data-feather="refresh-cw" class="w-4 h-4"></i>
</button>
<button class="text-gray-400 hover:text-white transition">
<i data-feather="trash-2" class="w-4 h-4"></i>
</button>
</div>
</div>
<div class="output-panel flex-grow p-4 overflow-auto">
<pre class="text-sm text-green-400">$ python main.py
Code Analysis Results:
Module: 1
FunctionDef: 2
arguments: 2
If: 1
Compare: 1
Num: 2
Return: 2
BinOp: 1
Sub: 1
Call: 3
Name: 6
Load: 6
Str: 1
Expr: 1
</pre>
</div>
</div>
</div>
</div>
<!-- Analysis Section -->
<div class="mt-8 bg-gray-800 rounded-xl p-6">
<h3 class="text-xl font-bold mb-4">Code Analysis</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="bg-gray-700 p-4 rounded-lg">
<div class="flex items-center justify-between mb-3">
<h4 class="font-medium">Complexity</h4>
<div class="bg-blue-500 bg-opacity-20 p-2 rounded-full">
<i data-feather="activity" class="w-4 h-4 text-blue-400"></i>
</div>
</div>
<div class="flex items-end space-x-2">
<span class="text-3xl font-bold">2.4</span>
<span class="text-green-400 text-sm">-0.3 from avg</span>
</div>
<div class="w-full bg-gray-600 rounded-full h-2 mt-2">
<div class="bg-blue-500 h-2 rounded-full" style="width: 48%"></div>
</div>
</div>
<div class="bg-gray-700 p-4 rounded-lg">
<div class="flex items-center justify-between mb-3">
<h4 class="font-medium">Style Score</h4>
<div class="bg-green-500 bg-opacity-20 p-2 rounded-full">
<i data-feather="check-circle" class="w-4 h-4 text-green-400"></i>
</div>
</div>
<div class="flex items-end space-x-2">
<span class="text-3xl font-bold">87%</span>
<span class="text-green-400 text-sm">+12% from avg</span>
</div>
<div class="w-full bg-gray-600 rounded-full h-2 mt-2">
<div class="bg-green-500 h-2 rounded-full" style="width: 87%"></div>
</div>
</div>
<div class="bg-gray-700 p-4 rounded-lg">
<div class="flex items-center justify-between mb-3">
<h4 class="font-medium">Issues</h4>
<div class="bg-yellow-500 bg-opacity-20 p-2 rounded-full">
<i data-feather="alert-triangle" class="w-4 h-4 text-yellow-400"></i>
</div>
</div>
<div class="flex items-end space-x-2">
<span class="text-3xl font-bold">3</span>
<span class="text-red-400 text-sm">+1 from avg</span>
</div>
<div class="mt-2 space-y-1">
<div class="flex items-center text-sm text-yellow-400">
<i data-feather="chevron-right" class="w-3 h-3 mr-1"></i>
Line 15: Unused variable 'v'
</div>
<div class="flex items-center text-sm text-yellow-400">
<i data-feather="chevron-right" class="w-3 h-3 mr-1"></i>
Line 5: Missing docstring
</div>
</div>
</div>
</div>
</div>
<!-- Toolbar -->
<div class="mt-6 flex justify-end space-x-3">
<button class="bg-gray-800 hover:bg-gray-700 px-4 py-2 rounded-lg flex items-center space-x-2 transition">
<i data-feather="settings" class="w-4 h-4"></i>
<span>Settings</span>
</button>
<button class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded-lg flex items-center space-x-2 transition">
<i data-feather="download" class="w-4 h-4"></i>
<span>Export</span>
</button>
</div>
</div>
<script>
feather.replace();
</script>
</body>
</html>
|