hhelesto commited on
Commit
d1d6660
·
verified ·
1 Parent(s): 49a71c5

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +71 -0
templates/index.html ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>AI Comment Generator</title>
7
+ <style>
8
+ body {
9
+ font-family: sans-serif;
10
+ max-width: 600px;
11
+ margin: 40px auto;
12
+ padding: 20px;
13
+ background: #f7f7f7;
14
+ border-radius: 8px;
15
+ }
16
+ textarea {
17
+ width: 100%;
18
+ height: 100px;
19
+ margin-bottom: 10px;
20
+ font-size: 16px;
21
+ padding: 10px;
22
+ }
23
+ button {
24
+ padding: 10px 20px;
25
+ font-size: 16px;
26
+ cursor: pointer;
27
+ }
28
+ #result {
29
+ margin-top: 20px;
30
+ white-space: pre-wrap;
31
+ background: #fff;
32
+ padding: 10px;
33
+ border-radius: 4px;
34
+ min-height: 50px;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body>
39
+ <h1>AI Comment Generator</h1>
40
+ <form id="promptForm">
41
+ <label for="prompt">Enter your prompt:</label><br>
42
+ <textarea id="prompt" name="prompt"></textarea><br>
43
+ <button type="submit">Generate</button>
44
+ </form>
45
+ <div id="result"></div>
46
+
47
+ <script>
48
+ const form = document.getElementById('promptForm');
49
+ const resultDiv = document.getElementById('result');
50
+
51
+ form.addEventListener('submit', async (e) => {
52
+ e.preventDefault();
53
+
54
+ const prompt = document.getElementById('prompt').value;
55
+
56
+ resultDiv.textContent = "Generating...";
57
+
58
+ const res = await fetch('/generate', {
59
+ method: 'POST',
60
+ headers: {
61
+ 'Content-Type': 'application/json'
62
+ },
63
+ body: JSON.stringify({ prompt })
64
+ });
65
+
66
+ const data = await res.json();
67
+ resultDiv.textContent = data.generated_text || "Error generating text.";
68
+ });
69
+ </script>
70
+ </body>
71
+ </html>