rust server working :) !!!

This commit is contained in:
unurled 2023-02-16 13:30:06 +01:00
parent d625ced9b1
commit e00ab6183c
33 changed files with 410 additions and 1159 deletions

17
public/js/edit.js Normal file
View file

@ -0,0 +1,17 @@
function saveText() {
let x = document.getElementById("text").value;
const options = {method: 'POST', body: JSON.stringify({text: x}), headers: { 'Content-Type': 'application/json' }};
fetch('http://127.0.0.1:8000/api/edit', options)
.then((response) => response.text())
.then(data => {
redirectOrNot(data);
})
.catch(err => console.error(err));
}
async function redirectOrNot(res) {
let url = "http://" + location.hostname + ":" + location.port
location.href = url+res
}

17
public/js/login.js Normal file
View file

@ -0,0 +1,17 @@
function formLink() {
let x = document.getElementById("Token").value;
const options = {method: 'POST', headers: {Token: x}};
fetch('http://127.0.0.1:8000/login', options)
.then((response) => response.text())
.then(data => {
redirectOrNot(data);
})
.catch(err => console.log(err));
}
async function redirectOrNot(res) {
let url = "http://" + location.hostname + ":" + location.port
location.href = url+res
}

18
public/js/main.js Normal file
View file

@ -0,0 +1,18 @@
!async function(){
let data = await fetch("http://localhost:8000/api")
.then((response) => response.text())
.then(data => {
return data;
})
.catch(error => {
console.error(error);
});
console.log(data);
print(data);
}();
function print(data) {
document.getElementById("text").innerText = data
document.getElementById("text").value = data
}