so THATS how it works
This commit is contained in:
parent
dfbe9e7b6c
commit
0ea65fcddf
|
@ -8,7 +8,7 @@ use rocket::serde::{Deserialize, json::Json};
|
|||
|
||||
#[get("/")]
|
||||
fn hello() -> String {
|
||||
fs::read_to_string("/home/sadlynotsappho/Projects/Web/website/root/index.html").unwrap()
|
||||
fs::read_to_string("/home/sadlynotsappho/Projects/Rust/Projects/fossil/web/index.html").unwrap()
|
||||
// format!("hi!!!")
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ async fn login(info: Json<LoginInfo>) -> &'static str {
|
|||
async fn main() {
|
||||
let _rocket = rocket::build()
|
||||
.mount("/", routes![hello, get_book, delay, login])
|
||||
.mount("/root", FileServer::from("/home/sadlynotsappho/Projects/Web/website/root"))
|
||||
.mount("/root", FileServer::from("/home/sadlynotsappho/Projects/Rust/Projects/fossil/web"))
|
||||
.launch()
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>login test</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body>
|
||||
hiii
|
||||
<form action="http://127.0.0.1:8000/login" method="post" class="form-test" id="balls">
|
||||
<div class="form-test">
|
||||
<label for="name">Enter your username: </label>
|
||||
<input type="text" name="username" id="name" required />
|
||||
</div>
|
||||
<div class="form-test">
|
||||
<label for="pass">Enter your password: </label>
|
||||
<input type="text" name="password" id="password" required />
|
||||
</div>
|
||||
<div class="form-test">
|
||||
<input type="submit" value="Log in" />
|
||||
</div>
|
||||
</body>
|
||||
<script defer>
|
||||
console.log("FUCK YEAH JAVASCRIPT TIME BABYYYYYYY");
|
||||
document.getElementById("balls").addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const username = event.target.username.value;
|
||||
const password = event.target.password.value;
|
||||
|
||||
const token = await fetch("http://127.0.0.1:8000/login", {
|
||||
method: "POST",
|
||||
header: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify({username, password})
|
||||
})
|
||||
console.log(await token.text())
|
||||
})
|
||||
</script>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue