Update static/index.html
Browse files- static/index.html +27 -49
static/index.html
CHANGED
|
@@ -1,57 +1,35 @@
|
|
| 1 |
-
<!
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
body { font-family: Arial, sans-serif; margin: 30px; background: #f9f9f9; }
|
| 8 |
-
.container { max-width: 600px; margin: auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
|
| 9 |
-
input, button { width: 100%; padding: 10px; margin-top: 10px; border-radius: 5px; border: 1px solid #ccc; font-size: 16px; }
|
| 10 |
-
button { background-color: #007bff; color: white; border: none; cursor: pointer; }
|
| 11 |
-
button:hover { background-color: #0056b3; }
|
| 12 |
-
.card { background: #f4f4f4; padding: 15px; border-radius: 5px; margin-top: 15px; white-space: pre-wrap; }
|
| 13 |
-
h2, h3 { text-align: center; }
|
| 14 |
-
</style>
|
| 15 |
</head>
|
| 16 |
<body>
|
| 17 |
-
|
| 18 |
-
<
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
const responseEl = document.getElementById("response");
|
| 34 |
-
|
| 35 |
-
if (!question) {
|
| 36 |
-
responseEl.textContent = "Please enter a question.";
|
| 37 |
-
return;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
responseEl.textContent = "Loading...";
|
| 41 |
-
|
| 42 |
-
try {
|
| 43 |
-
const resp = await fetch(`/answers?question=${encodeURIComponent(question)}&max_new_tokens=${maxTokens}`);
|
| 44 |
-
const data = await resp.json();
|
| 45 |
-
|
| 46 |
-
// Structured display
|
| 47 |
-
responseEl.innerHTML = `
|
| 48 |
-
<strong>Question:</strong> ${data.question}<br/><br/>
|
| 49 |
-
<strong>Answer:</strong><br/>${data.answer.replace(/\n/g, "<br/>")}
|
| 50 |
-
`;
|
| 51 |
-
} catch (err) {
|
| 52 |
-
responseEl.textContent = "Error: " + err;
|
| 53 |
-
}
|
| 54 |
-
});
|
| 55 |
-
</script>
|
| 56 |
</body>
|
| 57 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Python Visualizer</title>
|
| 6 |
+
<link rel="stylesheet" href="/static/style.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
</head>
|
| 8 |
<body>
|
| 9 |
+
<h2>🧠 Python Visualizer</h2>
|
| 10 |
+
<form method="post" action="/run">
|
| 11 |
+
<textarea name="code" rows="10" cols="70" placeholder="Enter Python code here...">{{ code or '' }}</textarea><br>
|
| 12 |
+
<button type="submit">Run Code</button>
|
| 13 |
+
</form>
|
| 14 |
|
| 15 |
+
{% if trace %}
|
| 16 |
+
<h3>Execution Trace:</h3>
|
| 17 |
+
<ol>
|
| 18 |
+
{% for step in trace %}
|
| 19 |
+
{% if step.error %}
|
| 20 |
+
<li style="color:red;">Error: {{ step.error }}</li>
|
| 21 |
+
{% else %}
|
| 22 |
+
<li>
|
| 23 |
+
<strong>Line {{ step.line }}</strong> → Locals: {{ step.locals }}
|
| 24 |
+
</li>
|
| 25 |
+
{% endif %}
|
| 26 |
+
{% endfor %}
|
| 27 |
+
</ol>
|
| 28 |
+
{% endif %}
|
| 29 |
|
| 30 |
+
{% if output %}
|
| 31 |
+
<h3>Output:</h3>
|
| 32 |
+
<pre>{{ output }}</pre>
|
| 33 |
+
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
</body>
|
| 35 |
</html>
|