-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (29 loc) · 1.13 KB
/
script.js
File metadata and controls
36 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const loginForm = document.getElementById("loginForm");
loginForm.addEventListener("submit", async (event) => {
event.preventDefault(); // Prevent form from submitting the default way
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
try {
const response = await fetch("http://127.0.0.1:8000/auth/login/", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: email,
password: password
}),
})
const result = await response.json();
if (response.ok) {
//alert("Login successful! Redirecting to PyMentorBot...");
window.location.href = "file:///C:/Users/User/Downloads/login/static/lesson/index1.html"; // Redirect to PyMentorBot interface
} else {
alert(`Error: ${result.detail}`);
}
} catch (error) {
console.error("Error logging in:", error);
alert("An error occurred. Please try again later.");
}
});
//<a href="http://127.0.0.1:8000/pymentorbot" target="_blank">Go to PyMentorBot</a>