Skip to content

Commit

Permalink
Merge pull request #71 from shim-pyoo/fix/#65-flask
Browse files Browse the repository at this point in the history
πŸ› FIX. Flask μ„œλ²„μ™€μ˜ 톡신 μˆ˜μ •
  • Loading branch information
frombunny authored Sep 9, 2024
2 parents ffeef6f + 60e3da0 commit f2b2527
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void deleteBreathing() {
}

// ν”ŒλΌμŠ€ν¬ μ„œλ²„ μ—”λ“œν¬μΈνŠΈ
String flaskUrl = "http://localhost:5001/analyze";
String flaskUrl = "http://15.165.141.134:5001/analyze";

// Flask μ„œλ²„λ‘œ POST μš”μ²­μ„ λ³΄λ‚΄μ„œ PEF 값을 λ°›μ•„μ˜΄
ResponseEntity<Map> response = restTemplate.postForEntity(flaskUrl, breathingFlaskRequestDto, Map.class);
Expand All @@ -166,7 +166,7 @@ public void deleteBreathing() {
.third(pefValues.get("pef_3"))
.build();

// μ΅œλŒ€ 수치 μ„œλ ‚γ…‡
// μ΅œλŒ€ 수치 μ„€μ •
Double maxPef = Math.max(breathingPefDto.getFirst(),
Math.max(breathingPefDto.getSecond(), breathingPefDto.getThird()));

Expand All @@ -185,6 +185,11 @@ public void deleteBreathing() {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "톡신 쀑 μ„œλ²„ 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.");
}

// 응닡 본문이 λΉ„μ–΄ μžˆλŠ” 경우 μ˜ˆμ™Έ 처리
if (response.getBody() == null) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "μ„œλ²„λ‘œλΆ€ν„° μ˜¬λ°”λ₯Έ 응닡을 받지 λͺ»ν–ˆμŠ΅λ‹ˆλ‹€.");
}

return newBreathing;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public CustomAPIResponse<Map<String, Object>> calculateBreathingResult(Breathing
Map<String, Object> responseData = new LinkedHashMap<>();
responseData.put("status", state.getDescription()); // ν•œκ΅­μ–΄ μ„€λͺ…μœΌλ‘œ λ°˜ν™˜
responseData.put("breathingRate", maxBreathingRate);
responseData.put("rateDifference", rateDifferencePercent + "% " + rateChangeDirection);
responseData.put("variance", rateDifferencePercent + "%"); // 증감λ₯ 
responseData.put("rateChangeDirection", rateChangeDirection);
responseData.put("first", todayBreathing.getFirst());
responseData.put("second", todayBreathing.getSecond());
responseData.put("third", todayBreathing.getThird());
Expand Down

0 comments on commit f2b2527

Please sign in to comment.