Готовая
This commit is contained in:
parent
97a239d1b1
commit
f3f1920485
@ -2,7 +2,6 @@ package com.LabWork.app;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -16,34 +15,29 @@ public class AppApplication {
|
||||
SpringApplication.run(AppApplication.class, args);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/hello")
|
||||
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
|
||||
return String.format("Hello %s!", name);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/sum")
|
||||
public String Sum(@RequestParam(required = false, defaultValue = "0") double first,
|
||||
@RequestParam(required = false, defaultValue = "0") double second) {
|
||||
return Double.toString(first + second);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/difference")
|
||||
public String Difference(@RequestParam(required = false, defaultValue = "0") double first,
|
||||
@RequestParam(required = false, defaultValue = "0") double second) {
|
||||
return Double.toString(first - second);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/multiplication")
|
||||
public String Multiplication(@RequestParam(required = false, defaultValue = "1") double first,
|
||||
@RequestParam(required = false, defaultValue = "1") double second) {
|
||||
return Double.toString(first * second);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/division")
|
||||
public String Division(@RequestParam(required = false, defaultValue = "1") double first,
|
||||
@RequestParam(required = false, defaultValue = "1") double second) {
|
||||
@ -53,4 +47,10 @@ public class AppApplication {
|
||||
}
|
||||
return Double.toString(first/second);
|
||||
}
|
||||
|
||||
@GetMapping("/binary")
|
||||
public String Binary(@RequestParam int result) {
|
||||
return Double.toString(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
13
src/main/java/com/LabWork/app/WebConfiguration.java
Normal file
13
src/main/java/com/LabWork/app/WebConfiguration.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.LabWork.app;
|
||||
|
||||
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("*");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user