This commit is contained in:
VictoriaPresnyakova 2023-02-14 11:27:41 +04:00
parent ca9e188161
commit aa2273c97f
3 changed files with 51 additions and 1 deletions

10
front/index.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>

View File

@ -2,12 +2,37 @@ 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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.websocket.server.PathParam;
import java.util.Date;
@SpringBootApplication
@RestController
public class SbappApplication {
public static void main(String[] args) {
SpringApplication.run(SbappApplication.class, args);
}
@GetMapping("/hello")
public Character hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return name.charAt(0);
}
@GetMapping("/hello_1/{name}")
public String hello_1(@PathVariable String name, @RequestParam(required = false, defaultValue = "") String val) {
name = name + val;
return String.format("Hello %s!", name);
}
@GetMapping("/bd")
public Integer bd(@RequestParam int birthday) {
return new Date().getYear() % 100 + 2000 - birthday;
}
@GetMapping("/calc")
public String doSum(@RequestParam(value = "v1", defaultValue = "") String val1, @RequestParam(defaultValue = "0") int val2) {
return val1.substring(val2);
}
}

View File

@ -0,0 +1,15 @@
package ru.ulstu.is.sbapp;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistration;
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("*");
}
}