gaur3009 commited on
Commit
9d4f673
·
verified ·
1 Parent(s): 3c43927

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +97 -19
index.html CHANGED
@@ -1,19 +1,97 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Grammar Corrector</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ padding: 20px;
11
+ max-width: 600px;
12
+ margin: auto;
13
+ }
14
+
15
+ h1 {
16
+ color: #4CAF50;
17
+ }
18
+
19
+ textarea {
20
+ width: 100%;
21
+ height: 150px;
22
+ margin-top: 10px;
23
+ padding: 10px;
24
+ font-size: 1em;
25
+ }
26
+
27
+ button {
28
+ margin-top: 15px;
29
+ padding: 10px 20px;
30
+ font-size: 1em;
31
+ background-color: #4CAF50;
32
+ color: white;
33
+ border: none;
34
+ cursor: pointer;
35
+ }
36
+
37
+ button:hover {
38
+ background-color: #45a049;
39
+ }
40
+
41
+ .output {
42
+ margin-top: 30px;
43
+ }
44
+
45
+ .output p {
46
+ font-size: 1.1em;
47
+ }
48
+ </style>
49
+ </head>
50
+ <body>
51
+ <h1>Grammar Correction using T5</h1>
52
+
53
+ <textarea id="inputText" placeholder="Type your sentence here..."></textarea>
54
+ <button onclick="correctGrammar()">Correct Grammar</button>
55
+
56
+ <div class="output" id="result" style="display: none;">
57
+ <h3>Results:</h3>
58
+ <p><strong>Original:</strong> <span id="baselineText"></span></p>
59
+ <p><strong>Corrected:</strong> <span id="correctedText"></span></p>
60
+ <p><strong>Score:</strong> <span id="scoreText"></span></p>
61
+ </div>
62
+
63
+ <script>
64
+ async function correctGrammar() {
65
+ const text = document.getElementById("inputText").value.trim();
66
+
67
+ if (!text) {
68
+ alert("Please enter some text.");
69
+ return;
70
+ }
71
+
72
+ try {
73
+ const response = await fetch("http://127.0.0.1:5000/predict", {
74
+ method: "POST",
75
+ headers: {
76
+ "Content-Type": "application/json"
77
+ },
78
+ body: JSON.stringify({ text: text })
79
+ });
80
+
81
+ const data = await response.json();
82
+
83
+ if (response.ok) {
84
+ document.getElementById("baselineText").textContent = data.baseline;
85
+ document.getElementById("correctedText").textContent = data.improved;
86
+ document.getElementById("scoreText").textContent = data.score;
87
+ document.getElementById("result").style.display = "block";
88
+ } else {
89
+ alert("Error: " + (data.error || "Unknown error"));
90
+ }
91
+ } catch (error) {
92
+ alert("Request failed: " + error.message);
93
+ }
94
+ }
95
+ </script>
96
+ </body>
97
+ </html>