Compare commits
No commits in common. "LabWork01" and "main" have entirely different histories.
@ -1,41 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<form class="" id="form">
|
||||
<h2>Калькулятор</h2>
|
||||
<div class="container row">
|
||||
<div class="form-group col-3">
|
||||
<label>num1</label>
|
||||
<input name="num1" type="number" class="form-control col-3" placeholder="Первый аргумент">
|
||||
</div>
|
||||
<div class="form-group col-3">
|
||||
<label>Оператор</label>
|
||||
<select name="selected" id="inputState" class="form-control">
|
||||
<option selected>+</option>
|
||||
<option>-</option>
|
||||
<option>*</option>
|
||||
<option>/</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="form-group col-3">
|
||||
<label>num2</label>
|
||||
<input name="num2" type="number" class="form-control col-3" placeholder="Второй аргумент">
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary m-3">Посчитать</button>
|
||||
</form>
|
||||
|
||||
<h2 class="text" id="res"></h2>
|
||||
|
||||
<script src="./node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
<script src="../js/script.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,39 +0,0 @@
|
||||
let form = document.getElementById("form");
|
||||
let info = document.getElementById("res");
|
||||
|
||||
|
||||
form.onsubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
if(form.num1.value === "") return;
|
||||
if(form.num2.value === "") return;
|
||||
|
||||
let index = form.selected.selectedIndex;
|
||||
|
||||
let op = form.selected.options[index].textContent;
|
||||
let res = "";
|
||||
|
||||
switch(op) {
|
||||
case "+":
|
||||
res = await fetch(`http://localhost:8080/sum?num1=${form.num1.value}&num2=${form.num2.value}`)
|
||||
res = await res.text();
|
||||
break;
|
||||
case "-":
|
||||
res = await fetch(`http://localhost:8080/diff?num1=${form.num1.value}&num2=${form.num2.value}`)
|
||||
res = await res.text();
|
||||
break;
|
||||
|
||||
case "*":
|
||||
res = await fetch(`http://localhost:8080/multiply?num1=${form.num1.value}&num2=${form.num2.value}`)
|
||||
res = await res.text();
|
||||
break;
|
||||
|
||||
case "/":
|
||||
if(form.num2.value == 0) return;
|
||||
res = await fetch(`http://localhost:8080/divide?num1=${form.num1.value}&num2=${form.num2.value}`)
|
||||
res = await res.text();
|
||||
break;
|
||||
}
|
||||
|
||||
info.textContent = res;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "http-server -p 3000 -c-1 -o ./"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bootstrap": "^5.2.3",
|
||||
"http-server": "^14.1.1"
|
||||
}
|
||||
}
|
@ -14,28 +14,25 @@ public class SbappApplication {
|
||||
SpringApplication.run(SbappApplication.class, args);
|
||||
}
|
||||
|
||||
@GetMapping("/sum")
|
||||
public Integer sum(@RequestParam Integer num1,
|
||||
@RequestParam Integer num2) {
|
||||
@GetMapping("/hello")
|
||||
public String hello() {
|
||||
return "Hello, i'm working!";
|
||||
}
|
||||
|
||||
@GetMapping("/ToUpper")
|
||||
public String ToUpper(@RequestParam(value = "", defaultValue = "default") String text) {
|
||||
return String.format(text).toUpperCase();
|
||||
}
|
||||
|
||||
@GetMapping("/calc")
|
||||
public Integer calc(@RequestParam(defaultValue = "10") Integer num1,
|
||||
@RequestParam(defaultValue = "10") Integer num2) {
|
||||
return num1 + num2;
|
||||
}
|
||||
|
||||
@GetMapping("/diff")
|
||||
public Integer diff(@RequestParam Integer num1,
|
||||
@RequestParam Integer num2) {
|
||||
return num1 - num2;
|
||||
}
|
||||
|
||||
@GetMapping("/multiply")
|
||||
public Integer multiply(@RequestParam Integer num1,
|
||||
@RequestParam Integer num2) {
|
||||
return num1 * num2;
|
||||
}
|
||||
|
||||
@GetMapping("/divide")
|
||||
public Integer divide(@RequestParam Integer num1,
|
||||
@RequestParam Integer num2) {
|
||||
return num1 / num2;
|
||||
@GetMapping("/concate")
|
||||
public String concate(@RequestParam String text) {
|
||||
return "Word-"+ text;
|
||||
}
|
||||
|
||||
@GetMapping("/divider")
|
||||
|
@ -1,13 +0,0 @@
|
||||
package ru.ulstu.is.sbapp;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfiguration implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
}
|
3
src/main/resources/static/styles.css
Normal file
3
src/main/resources/static/styles.css
Normal file
@ -0,0 +1,3 @@
|
||||
h1 {
|
||||
color: red;
|
||||
}
|
7
src/main/resources/static/test.js
Normal file
7
src/main/resources/static/test.js
Normal file
@ -0,0 +1,7 @@
|
||||
function test() {
|
||||
fetch("http://localhost:8080/hello", {
|
||||
mode:
|
||||
}
|
||||
}
|
||||
|
||||
test();
|
11
src/main/resources/templates/index.html
Normal file
11
src/main/resources/templates/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th = "http://www.thymeleaf.org">
|
||||
<head>
|
||||
<link rel="stylesheet" href="/styles.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1> IA WORK!</h1>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user