Добавлен фронтенд
This commit is contained in:
parent
c8fe76f814
commit
1c461b1134
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,3 +35,4 @@ out/
|
|||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
/node_modules/
|
||||||
|
41
front/MyScript.js
Normal file
41
front/MyScript.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
function setResult(result) {
|
||||||
|
let lbl = `<label class="bg-success">Ответ:${result}</label>`;
|
||||||
|
document.getElementById("result").innerHTML = lbl;
|
||||||
|
}
|
||||||
|
let addButton = document.getElementById("getResultAdd");
|
||||||
|
let a = document.getElementById("addNum1");
|
||||||
|
let b = document.getElementById("addNum2");
|
||||||
|
let Output = document.getElementById("addAnswer");
|
||||||
|
let address = "hello"
|
||||||
|
function add(){
|
||||||
|
address = "add"
|
||||||
|
executeRequest();
|
||||||
|
}
|
||||||
|
function sub(){
|
||||||
|
address = "sub"
|
||||||
|
executeRequest();
|
||||||
|
}
|
||||||
|
function mul(){
|
||||||
|
address = "mul"
|
||||||
|
executeRequest();
|
||||||
|
}
|
||||||
|
function del(){
|
||||||
|
|
||||||
|
address = "del"
|
||||||
|
if(b.value != 0) executeRequest();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function executeRequest() {
|
||||||
|
|
||||||
|
let num1 = a.value;
|
||||||
|
let num2 = b.value;
|
||||||
|
console.log("a" + num1 + "b" + num2)
|
||||||
|
fetch(`http://localhost:8080/${address}?a=${num1}&b=${num2}`)
|
||||||
|
.then(response => {
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(result => {
|
||||||
|
setResult(result);
|
||||||
|
})
|
||||||
|
}
|
0
front/data.json
Normal file
0
front/data.json
Normal file
31
front/index.html
Normal file
31
front/index.html
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Bootstrap demo</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>
|
||||||
|
<main>
|
||||||
|
<h4 class="mb-3">Команды</h4>
|
||||||
|
<p>Сложение</p>
|
||||||
|
<input type="number" class="form-control" id="addNum1" placeholder="" value="0" required="" style="width: 10%;">
|
||||||
|
<input type="number" class="form-control" id="addNum2" placeholder="" value="0" required="" style="width: 10%;">
|
||||||
|
|
||||||
|
<button class="btn btn-success" onclick="add()">Сложить</button>
|
||||||
|
<button class="btn btn-success" onclick="sub()">Вычесть</button>
|
||||||
|
<button class="btn btn-success" onclick="mul()">Умножить</button>
|
||||||
|
<button class="btn btn-success" onclick="del()">Поделить</button>
|
||||||
|
|
||||||
|
<div id="result">Ответ:</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</main>
|
||||||
|
<script src="MyScript.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
12
front/index.js
Normal file
12
front/index.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const http = require('http')
|
||||||
|
|
||||||
|
const requestListener = async function (req, res) {
|
||||||
|
res.writeHead(200);
|
||||||
|
fs.readFile('index.html', (err, data) => {
|
||||||
|
res.end(data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const server = http.createServer(requestListener)
|
||||||
|
server.listen(5050)
|
18
front/node_modules/.package-lock.json
generated
vendored
Normal file
18
front/node_modules/.package-lock.json
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "front",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/fs": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
|
||||||
|
},
|
||||||
|
"node_modules/http": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
39
front/package-lock.json
generated
Normal file
39
front/package-lock.json
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "front",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "front",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"fs": "0.0.1-security",
|
||||||
|
"http": "0.0.1-security"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fs": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
|
||||||
|
},
|
||||||
|
"node_modules/http": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"fs": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"version": "0.0.1-security",
|
||||||
|
"resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz",
|
||||||
|
"integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
front/package.json
Normal file
17
front/package.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "front",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.html",
|
||||||
|
"scripts": {
|
||||||
|
"start": "http-server -p 8079 ./",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"fs": "0.0.1-security",
|
||||||
|
"http": "0.0.1-security"
|
||||||
|
},
|
||||||
|
"devDependencies": { "http-server": "14.1.1"},
|
||||||
|
"description": ""
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user