diff --git a/.gitignore b/.gitignore index c2065bc..b44e9d7 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ out/ ### VS Code ### .vscode/ +/node_modules/ diff --git a/front/MyScript.js b/front/MyScript.js new file mode 100644 index 0000000..7907977 --- /dev/null +++ b/front/MyScript.js @@ -0,0 +1,41 @@ +function setResult(result) { + let lbl = ``; + 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); + }) +} \ No newline at end of file diff --git a/front/data.json b/front/data.json new file mode 100644 index 0000000..e69de29 diff --git a/front/index.html b/front/index.html new file mode 100644 index 0000000..5247738 --- /dev/null +++ b/front/index.html @@ -0,0 +1,31 @@ + + + + + + Bootstrap demo + + + + +
+

Команды

+

Сложение

+ + + + + + + + +
Ответ:
+ + + +
+ + + + + \ No newline at end of file diff --git a/front/index.js b/front/index.js new file mode 100644 index 0000000..69dc105 --- /dev/null +++ b/front/index.js @@ -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) \ No newline at end of file diff --git a/front/node_modules/.package-lock.json b/front/node_modules/.package-lock.json new file mode 100644 index 0000000..828d3a3 --- /dev/null +++ b/front/node_modules/.package-lock.json @@ -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==" + } + } +} diff --git a/front/package-lock.json b/front/package-lock.json new file mode 100644 index 0000000..b1e80cb --- /dev/null +++ b/front/package-lock.json @@ -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==" + } + } +} diff --git a/front/package.json b/front/package.json new file mode 100644 index 0000000..79b4ddf --- /dev/null +++ b/front/package.json @@ -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": "" +}