-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
79 lines (75 loc) · 2.63 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
</head>
<body>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<div id="app" class="container">
<form @submit.prevent="submitForm" class="row g-2">
<div class="col-4">
<label for="number_one">First number:</label><br>
<input id="number_one" type="number" v-model="number_one" required min="1"/>
</div>
<div class="col-4">
<label for="operator">Operator:</label><br>
<input id="operator" type="text" v-model="operator" required/>
</div>
<div class="col-4">
<label for="number_two">Second number:</label><br>
<input id="number_two" type="number" v-model="number_two" min="0" required/>
</div>
<div class="col-12 mt-3">
<button type="submit" class="btn btn-primary">Result</button>
</div>
</form>
<div class="row mt-2 g-2">
<div class="col-3">
<h6>Result arithmetic operation:</h6>
</div>
<div class="col-3">
<p>{{ result }}</p>
</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data() {
return {
number_one: 1,
number_two: 0,
operator: '',
response: '',
result: '',
success: '',
activeClass: 'active'
}
},
methods: {
submitForm() {
axios({
method: 'post',
url: 'http://127.0.0.1:8000/calc',
headers: {"Access-Control-Allow-Origin": "*"},
data: {
number_1: this.number_one,
number_2: this.number_two,
operator: this.operator
}
}).then(response => {
this.success = 'Result calculate';
this.response = JSON.stringify(response, null, 2)
this.result = response.data.result
}).catch(error => {
this.result = error.response.data.result
})
}
}
})
</script>
</body>
</html>