rabiyulfahim commited on
Commit
3fda900
·
verified ·
1 Parent(s): 079a804

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +27 -49
static/index.html CHANGED
@@ -1,57 +1,35 @@
1
- <!doctype html>
2
  <html lang="en">
3
  <head>
4
- <meta charset="utf-8" />
5
- <title>QA GPT2 Interface</title>
6
- <style>
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
- <div class="container">
18
- <h2>Ask GPT2</h2>
19
- <input id="question" placeholder="Type your question..." />
20
- <input id="tokens" type="number" value="50" min="1" max="200" placeholder="Max tokens" />
21
- <button id="askBtn">Ask</button>
22
 
23
- <div id="responseContainer">
24
- <h3>Response:</h3>
25
- <div id="response" class="card">No answer yet.</div>
26
- </div>
27
- </div>
 
 
 
 
 
 
 
 
 
28
 
29
- <script>
30
- document.getElementById("askBtn").addEventListener("click", async () => {
31
- const question = document.getElementById("question").value.trim();
32
- const maxTokens = document.getElementById("tokens").value;
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>