Добавлен фронтенд

This commit is contained in:
dimazhelovanov 2023-02-20 21:24:04 +03:00
parent bb58d473a3
commit c8fe76f814
2 changed files with 48 additions and 3 deletions

View File

@ -2,9 +2,9 @@ package ru.ulstu.is.myapp;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import java.util.Date;
@SpringBootApplication @SpringBootApplication
@ -14,10 +14,41 @@ public class MyappApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(MyappApplication.class, args); SpringApplication.run(MyappApplication.class, args);
} }
@GetMapping("/hello") @GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) { public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name); return String.format("Hello %s!", name);
} }
@CrossOrigin
@GetMapping(value = "/add")
public Integer doSum(@RequestParam(value = "a", defaultValue = "0") int a,
@RequestParam(value = "b", defaultValue = "0") int b){
return a + b;
}
@GetMapping("/sub")
public Integer doSub(@RequestParam(value = "a", defaultValue = "0") int a,
@RequestParam(value = "b", defaultValue = "0") int b){
return a - b;
}
@GetMapping("/mul")
public Integer doMul(@RequestParam(value = "a", defaultValue = "0") int a,
@RequestParam(value = "b", defaultValue = "0") int b){
return a * b;
}
@GetMapping("/del")
public Integer doDel(@RequestParam(value = "a", defaultValue = "0") int a,
@RequestParam(value = "b", defaultValue = "1") int b){
return a / b;
}
@GetMapping("/mu")
public String len(@RequestParam(value = "word", defaultValue = "") String name){
return String.format("Длина слова " + name + " " + len(name));
}
@GetMapping("/de")
public String root(){
return new Date().toString();
}

View File

@ -0,0 +1,14 @@
package ru.ulstu.is.myapp;
import org.springframework.beans.factory.annotation.Configurable;
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("*");
}
}