Spaces:
Sleeping
Sleeping
Download static/scripts/login.js from Arcader7171/InterState: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/Arcader7171/InterState/resolve/main/static/scripts/login.js
- Command line
-
hf download hf://spaces/Arcader7171/InterState/static/scripts/login.js
-
curl -L -o login.js https://huggingface.co/spaces/Arcader7171/InterState/resolve/main/static/scripts/login.js
1.45 kB
| function login() { | |
| console.log("Function login started") | |
| let userInput = document.getElementById("userInput"); | |
| let passInput = document.getElementById("passInput"); | |
| fetch("/api/login", { | |
| method: 'POST', | |
| body: JSON.stringify({"username": userInput.value, "password": passInput.value}) | |
| }) | |
| .then(response => { | |
| if (!response.ok) { | |
| throw response; // throw the entire response to read it in catch block; | |
| } | |
| return response.json(); | |
| }) | |
| .then(data => { | |
| console.log("Success - ", data); | |
| window.location.reload(); | |
| }) | |
| .catch(errorResponse => { | |
| if (errorResponse instanceof Response) { | |
| errorResponse.json() | |
| .then(errorData => { | |
| console.error('Error from server - ', errorData.message); | |
| }) | |
| .catch(jsonParseError => { | |
| console.error("Error parsing error from server", jsonParseError) | |
| errorResponse.text().then(textError => { | |
| console.error("Error as plain text - ", textError); | |
| }); | |
| }); | |
| } else { | |
| console.error("Unhandled error (network or other) - ", errorResponse); | |
| } | |
| }); | |
| } | |
| document.addEventListener("DOMContentLoaded", (event) => { | |
| let button = document.getElementById("submit"); | |
| button.addEventListener("click", (event) => {login()}) | |
| }) | |
| document.addEventListener("keydown", (event) => { | |
| if (event.key === "Enter") {console.log("Enter pressed"); login()} | |
| }) |