parse_py / templates /index.html
broadfield-dev's picture
Update templates/index.html
e1e8a7c verified
raw
history blame
3.27 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Python Code Parser & Program Retrieval</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/[email protected]"></script>
<style>
.table-container { overflow-x: auto; }
pre { white-space: pre-wrap; word-wrap: break-word; }
</style>
</head>
<body class="bg-gray-900 text-gray-200 min-h-screen p-8 font-sans">
<div class="max-w-7xl mx-auto bg-gray-800 p-6 rounded-xl shadow-2xl">
<h1 class="text-3xl font-bold text-blue-400 mb-6">Python Code Parser & Program Retrieval</h1>
<!-- Parsing Form -->
<form hx-post="/" hx-target="#results" hx-swap="innerHTML" class="space-y-6 mb-8">
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">Upload a Python File</label>
<input type="file" name="file" accept=".py" class="w-full p-2 border rounded-lg bg-gray-700 text-gray-200">
</div>
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">Or Paste Your Code</label>
<textarea name="code" rows="6" class="w-full p-2 border rounded-lg bg-gray-700 text-gray-200" placeholder="Paste Python code here...">{{ code_input or '' }}</textarea>
<input type="text" name="filename" class="mt-2 w-full p-2 border rounded-lg bg-gray-700 text-gray-200" placeholder="Enter filename (e.g., script.py)" value="{{ filename or '' }}">
</div>
<button type="submit" class="w-full bg-blue-500 text-white p-2 rounded-lg hover:bg-blue-600 transition">Parse & Store</button>
</form>
<!-- Query Form -->
<form hx-post="/" hx-target="#results" hx-swap="innerHTML" class="space-y-4 mb-8">
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">Query Programs (e.g., function,assignment,return)</label>
<input type="text" name="query_ops" class="w-full p-2 border rounded-lg bg-gray-700 text-gray-200" placeholder="Enter operations (comma-separated)">
</div>
<button type="submit" class="w-full bg-green-500 text-white p-2 rounded-lg hover:bg-green-600 transition">Find Programs</button>
</form>
<!-- Results Section -->
<div id="results" class="mt-8">
{% if parts %}
{% include 'results_partial.html' %}
{% elif query_results %}
<h2 class="text-2xl font-bold text-blue-400 mb-4">Matching Programs</h2>
<div class="space-y-4">
{% for result in query_results %}
<div class="bg-gray-700 p-4 rounded-lg">
<h3 class="text-lg font-semibold text-blue-300">Program ID: {{ result.id }}</h3>
<p class="text-gray-200">Similarity: {{ result.similarity | round(3) }}</p>
<pre class="bg-gray-800 p-2 rounded mt-2 text-gray-300">{{ result.code }}</pre>
</div>
{% endfor %}
</div>
{% endif %}
</div>
</div>
</body>
</html>