Marthee commited on
Commit
173ee1c
·
verified ·
1 Parent(s): dee031c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +57 -1
index.html CHANGED
@@ -1,4 +1,4 @@
1
- <!doctype html>
2
  <html>
3
  <head>
4
  <meta charset="utf-8" />
@@ -17,3 +17,59 @@
17
  </div>
18
  </body>
19
  </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- <!doctype html>
2
  <html>
3
  <head>
4
  <meta charset="utf-8" />
 
17
  </div>
18
  </body>
19
  </html>
20
+ -->
21
+
22
+ <!doctype html>
23
+ <html>
24
+ <head>
25
+ <meta charset="utf-8" />
26
+ <meta name="viewport" content="width=device-width" />
27
+ <title>My static Space</title>
28
+ <link rel="stylesheet" href="style.css" />
29
+ <script>
30
+ async function sendData() {
31
+ // Get the value from the input field
32
+ const pdfText = document.getElementById('pdfText').value;
33
+
34
+ // Prepare the request payload
35
+ const payload = {
36
+ pdftext: pdfText
37
+ };
38
+
39
+ try {
40
+ // Send POST request to the Flask endpoint
41
+ const response = await fetch('https://huggingface.co/spaces/USERNAME/SPACE_NAME/process', {
42
+ method: 'POST',
43
+ headers: {
44
+ 'Content-Type': 'application/json'
45
+ },
46
+ body: JSON.stringify(payload)
47
+ });
48
+
49
+ // Parse and display the response
50
+ const result = await response.json();
51
+ document.getElementById('response').textContent = JSON.stringify(result, null, 2);
52
+ } catch (error) {
53
+ console.error('Error:', error);
54
+ document.getElementById('response').textContent = 'An error occurred.';
55
+ }
56
+ }
57
+ </script>
58
+ </head>
59
+ <body>
60
+ <div class="card">
61
+ <h1>Welcome to your static Space!</h1>
62
+ <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
63
+ <p>
64
+ Also don't forget to check the
65
+ <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
66
+ </p>
67
+ <div>
68
+ <h2>Send Data to Flask App</h2>
69
+ <textarea id="pdfText" rows="10" cols="30" placeholder="Enter text here..."></textarea><br/>
70
+ <button onclick="sendData()">Send Data</button>
71
+ <pre id="response"></pre>
72
+ </div>
73
+ </div>
74
+ </body>
75
+ </html>