Spaces:
Sleeping
Sleeping
Update static/index.html
Browse files- static/index.html +38 -0
static/index.html
CHANGED
|
@@ -1,5 +1,42 @@
|
|
| 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">
|
|
@@ -24,3 +61,4 @@
|
|
| 24 |
<p id="apiResponse"></p>
|
| 25 |
</body>
|
| 26 |
</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>Fetch API Example</title>
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<h1>FastAPI Data Fetch Example</h1>
|
| 10 |
+
<button id="fetchApi">Fetch API Message</button>
|
| 11 |
+
<button id="fetchCustomAuth">Fetch Custom Auth Token</button>
|
| 12 |
+
<p id="apiResponse"></p>
|
| 13 |
+
<p id="authResponse"></p>
|
| 14 |
+
|
| 15 |
+
<script>
|
| 16 |
+
document.getElementById('fetchApi').onclick = function() {
|
| 17 |
+
fetch('/api')
|
| 18 |
+
.then(response => response.json())
|
| 19 |
+
.then(data => {
|
| 20 |
+
document.getElementById('apiResponse').textContent = 'API Response: ' + data.message;
|
| 21 |
+
})
|
| 22 |
+
.catch(error => console.error('Error fetching API data:', error));
|
| 23 |
+
};
|
| 24 |
+
|
| 25 |
+
document.getElementById('fetchCustomAuth').onclick = function() {
|
| 26 |
+
fetch('/custom-auth')
|
| 27 |
+
.then(response => response.json())
|
| 28 |
+
.then(data => {
|
| 29 |
+
document.getElementById('authResponse').textContent = 'Custom Auth Token: ' + data.token;
|
| 30 |
+
})
|
| 31 |
+
.catch(error => console.error('Error fetching custom auth token:', error));
|
| 32 |
+
};
|
| 33 |
+
</script>
|
| 34 |
+
</body>
|
| 35 |
+
</html>
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
<!-- <!DOCTYPE html>
|
| 39 |
+
<html lang="en">
|
| 40 |
<head>
|
| 41 |
<meta charset="UTF-8">
|
| 42 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
| 61 |
<p id="apiResponse"></p>
|
| 62 |
</body>
|
| 63 |
</html>
|
| 64 |
+
-->
|