This commit is contained in:
Татьяна Артамонова 2023-03-14 10:31:02 +04:00
parent 0205fa1ec1
commit bdcbb61084
6 changed files with 160 additions and 5 deletions

View File

@ -1,10 +1,72 @@
<!DOCTYPE html>
<html lang="en">
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
<title>LabWork01</title>
<script src="/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-lg-6">
<h3 class="text-center font-weight-light my-2">Лабораторная работа 1</h3>
<form>
<div class="form-row">
<div class="col">
<div class="form-group">
<label for="input1">Первая строка</label>
<input type="text" class="form-control" id="input1" placeholder="Введите перую строку">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="input2">Вторая строка</label>
<input type="text" class="form-control" id="input2" placeholder="Введите вторую строку">
</div>
</div>
<button type="button" class="btn btn-primary btn-block" onclick="Sum()">Сумма</button>
<div class="col">
<div class="form-group">
<label for="input3">Строка</label>
<input type="text" class="form-control" id="input3" placeholder="Введите строку">
</div>
</div>
<button type="button" class="btn btn-primary btn-block" onclick="ToUpper()">В верхний регистр</button>
<div class="col">
<div class="form-group">
<label for="input4">Строка</label>
<input type="text" class="form-control" id="input4" placeholder="Введите строку">
<label for="input5">Разделитель</label>
<input type="text" class="form-control" id="input5" placeholder="Введите разделитель">
</div>
</div>
<button type="button" class="btn btn-primary btn-block" onclick="Split()">Разделить</button>
<div class="col">
<div class="form-group">
<label for="input6">Строка</label>
<input type="text" class="form-control" id="input6" placeholder="Введите строку">
<label for="input7">Новый символ</label>
<input type="text" class="form-control" id="input7" placeholder="Введите старый символ">
<label for="input8">Старый символ</label>
<input type="text" class="form-control" id="input8" placeholder="Введите новый символ">
</div>
</div>
<button type="button" class="btn btn-primary btn-block" onclick="Replace()">Заменить</button>
</div>
<div class="form-group">
<label for="result">Результат</label>
<input type="text" class="form-control result" id="result" readonly>
</div>
</form>
</div>
</div>
</div>
<script src = "script.js"></script>
</body>
</html>

15
front/package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "IP",
"version": "1.0.0",
"main": "index.html",
"scripts": {
"start": "http-server -p 3001 ./",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"bootstrap": "5.2.1"
},
"devDependencies": {
"http-server": "^14.1.1"
}
}

44
front/script.js Normal file
View File

@ -0,0 +1,44 @@
'use strict'
let num1 = document.getElementById("input1")
let num2 = document.getElementById("input2")
let num3 = document.getElementById("input3")
let num4 = document.getElementById("input4")
let num5 = document.getElementById("input5")
let num6 = document.getElementById("input6")
let num7 = document.getElementById("input7")
let num8 = document.getElementById("input8")
let operator = document.getElementById("operator")
let result = document.getElementById("result")
async function Sum(){
let str1 = num1.value
let str2 = num2.value
let response = await fetch(`http://localhost:8080/Sum/${str1}/${str2}`)
let res = await response.text()
result.value = res
}
async function ToUpper(){
let str3 = num3.value
let response = await fetch(`http://localhost:8080/ToUpper/${str3}`)
let res = await response.text()
result.value = res
}
async function Split(){
let str4 = num4.value
let str5 = num5.value
let response = await fetch(`http://localhost:8080/Split/${str4}/${str5}`)
let res = await response.text()
result.value = res
}
async function Replace(){
let str6 = num6.value
let str7 = num7.value
let str8 = num8.value
let response = await fetch(`http://localhost:8080/Replace/${str6}/${str7}/${str8}`)
let res = await response.text()
result.value = res
}

View File

@ -1 +1 @@
rootProject.name = 'sbapp'
rootProject.name = 'PIbd-22_Artamonova_T.V._IP'

View File

@ -2,12 +2,33 @@ package ru.ulstu.is.sbapp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class SbappApplication {
public static void main(String[] args) {
SpringApplication.run(SbappApplication.class, args);
}
}
@GetMapping("/Sum/{val1}/{val2}")
public String Sum(@PathVariable String val1, @PathVariable String val2) {
return val1 + val2;
}
@GetMapping("/ToUpper/{str3}")
public String ToUpper(@PathVariable String str3) {
return str3.toUpperCase();
}
@GetMapping("/Split/{str1}/{str2}")
public String Split(@PathVariable String str1, @PathVariable String str2) {
String[] array = str1.split(str2);
return String.join(" ", array);
}
@GetMapping("/Replace/{str}/{oldChar}/{newChar}")
public String Replace(@PathVariable String str, @PathVariable char oldChar, @PathVariable char newChar) {
return str.replace(oldChar, newChar);
}
}

View File

@ -0,0 +1,13 @@
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
class WebConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
}