Spaces:
Running
Running
| <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> | |