Minhasapov_Network_Programming/frontend/index.html

30 lines
1.4 KiB
HTML
Raw Permalink Normal View History

2023-02-19 19:51:31 +04:00
<!DOCTYPE html>
<html>
<head>
<title>Calc</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<input type="number" class="form-control" id="num1">
<select class="form-control" id="operation">
<option value="sum">+</option>
<option value="sub">-</option>
<option value="mul">*</option>
<option value="div">/</option>
</select>
<input type="number" class="form-control" id="num2">
<button type="button" class="form-control btn btn-light" id="get-result" onclick="calc()">=</button>
<p class="h5" id="result"></p>
<script>
async function calc() {
const num1 = document.getElementById("num1").value
const num2 = document.getElementById("num2").value
document.getElementById("result").innerHTML = await (await fetch(`http://127.0.0.1:8080/${document.getElementById("operation").value}?num1=${num1}&num2=${num2}`)).text()
}
</script>
</body>
</html>