Spaces:
Runtime error
Runtime error
Download static/scripts/index.js from Timmyafolami/Weed-Detection-App: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/spaces/Timmyafolami/Weed-Detection-App/resolve/main/static/scripts/index.js
- Command line
-
hf download hf://spaces/Timmyafolami/Weed-Detection-App/static/scripts/index.js
-
curl -L -o index.js https://huggingface.co/spaces/Timmyafolami/Weed-Detection-App/resolve/main/static/scripts/index.js
1.54 kB
| document.addEventListener('DOMContentLoaded', () => { | |
| const registrationForm = document.getElementById('registrationForm'); | |
| if (registrationForm) { | |
| registrationForm.addEventListener('submit', async (e) => { | |
| e.preventDefault(); | |
| const name = document.getElementById('name').value; | |
| const email = document.getElementById('email').value; | |
| const phone = document.getElementById('phone').value; | |
| const address = document.getElementById('address').value; | |
| const userInfo = { | |
| "Name": name, | |
| "Email": email, | |
| "Address": address, | |
| "Phone Number": phone | |
| }; | |
| const response = await fetch('/register', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify(userInfo), | |
| }); | |
| const messageDiv = document.getElementById('message'); | |
| if (response.ok) { | |
| messageDiv.textContent = 'Registration successful! Redirecting to the application page...'; | |
| setTimeout(() => { | |
| window.location.href = '/app'; | |
| }, 2000); // Redirects after 2 seconds | |
| } else { | |
| const error = await response.json(); | |
| messageDiv.textContent = `Registration failed: ${error.detail}`; | |
| } | |
| }); | |
| } | |
| }); | |