ginipick commited on
Commit
8befdfa
·
verified ·
1 Parent(s): 6c1bcd3

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +86 -19
index.html CHANGED
@@ -1,19 +1,86 @@
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>Test /add_points_and_refresh_fn API</title>
7
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.js"></script>
8
+ </head>
9
+ <body class="bg-gray-100 p-8">
10
+ <div class="max-w-2xl mx-auto bg-white rounded-lg shadow-lg p-6">
11
+ <h1 class="text-3xl font-bold mb-6">Test /add_points_and_refresh_fn API</h1>
12
+
13
+ <div class="mb-4">
14
+ <label class="block text-gray-700 text-sm font-bold mb-2" for="email">
15
+ Email
16
+ </label>
17
+ <input type="email"
18
+ id="email"
19
+ class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
20
+ placeholder="Enter email">
21
+ </div>
22
+
23
+ <div class="mb-4">
24
+ <button id="submit"
25
+ class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
26
+ Submit
27
+ </button>
28
+ </div>
29
+
30
+ <div class="mb-4">
31
+ <label class="block text-gray-700 text-sm font-bold mb-2">
32
+ Status
33
+ </label>
34
+ <div id="status"
35
+ class="border rounded w-full py-2 px-3 text-gray-700 bg-gray-100">
36
+ </div>
37
+ </div>
38
+
39
+ <div class="mb-4">
40
+ <label class="block text-gray-700 text-sm font-bold mb-2">
41
+ Value
42
+ </label>
43
+ <div id="value"
44
+ class="border rounded w-full py-2 px-3 text-gray-700 bg-gray-100">
45
+ </div>
46
+ </div>
47
+ </div>
48
+
49
+ <script>
50
+ document.getElementById('submit').addEventListener('click', async () => {
51
+ const email = document.getElementById('email').value;
52
+ const statusElement = document.getElementById('status');
53
+ const valueElement = document.getElementById('value');
54
+
55
+ // Reset output fields
56
+ statusElement.textContent = 'Processing...';
57
+ valueElement.innerHTML = '';
58
+
59
+ try {
60
+ const response = await fetch('https://ginipick-Dokdo-pay.hf.space/add_points_and_refresh_fn', {
61
+ method: 'POST',
62
+ headers: {
63
+ 'Content-Type': 'application/json',
64
+ },
65
+ body: JSON.stringify({ email: email })
66
+ });
67
+
68
+ if (!response.ok) {
69
+ throw new Error(`HTTP error! status: ${response.status}`);
70
+ }
71
+
72
+ const data = await response.json();
73
+
74
+ // Assuming the API returns an array with status and value
75
+ statusElement.textContent = data[0];
76
+ valueElement.innerHTML = data[1];
77
+
78
+ } catch (error) {
79
+ statusElement.textContent = `Error: ${error.message}`;
80
+ valueElement.innerHTML = 'Error occurred';
81
+ console.error('Error:', error);
82
+ }
83
+ });
84
+ </script>
85
+ </body>
86
+ </html>