-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
54 lines (52 loc) · 1.68 KB
/
index.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<meta charset="UTF-8">
<title>sh.cluuub.xyz - URL shortener</title>
</head>
<body>
<header>
<h1 align="center">sh.cluuub.xyz- URL shortener</h1>
</header>
<div class="container-fluid" align="center" id="form">
<label for="shorthand">Shorthand:</label>
<input type="text" id="shorthand" name="shorthand">
<label for="url">URL:</label>
<input type="text" id="url" name="url">
<button type="button" id="bsubmit" name="bsubmit" onclick="submit()">Submit</button>
</div>
</body>
<style>
h1 {
padding:15px;
}
.container {
padding:25px;
}
</style>
<script>
async function submit(){
const shorthand = document.getElementById("shorthand").value
const url = document.getElementById("url").value
const res = await fetch(document.URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
shorthand: shorthand,
url: url
})
});
const responseText = await res.text()
if(!res.ok){
alert(responseText);
} else {
document.querySelector('#form').innerHTML = responseText;
}
}
</script>
</html>