Spaces:
Sleeping
Sleeping
KevanSoon
commited on
Commit
·
0048178
1
Parent(s):
37decb3
added Spring to support fastapi service
Browse files
src/main/java/com/cs102/attendance/controller/FastApiCallerController.java
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
package com.cs102.attendance.controller;
|
| 2 |
|
| 3 |
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -8,7 +9,11 @@ import com.cs102.attendance.service.FastApiCallerService;
|
|
| 8 |
@RestController
|
| 9 |
public class FastApiCallerController {
|
| 10 |
|
| 11 |
-
private final FastApiCallerService fastApiCallerService
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
@GetMapping("/call-face-recognition")
|
| 14 |
public String callFaceRecognition() {
|
|
@@ -19,4 +24,4 @@ public class FastApiCallerController {
|
|
| 19 |
return "Error calling face-recognition API";
|
| 20 |
}
|
| 21 |
}
|
| 22 |
-
}
|
|
|
|
| 1 |
+
// FastApiCallerController.java
|
| 2 |
package com.cs102.attendance.controller;
|
| 3 |
|
| 4 |
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
| 9 |
@RestController
|
| 10 |
public class FastApiCallerController {
|
| 11 |
|
| 12 |
+
private final FastApiCallerService fastApiCallerService;
|
| 13 |
+
|
| 14 |
+
public FastApiCallerController(FastApiCallerService fastApiCallerService) {
|
| 15 |
+
this.fastApiCallerService = fastApiCallerService;
|
| 16 |
+
}
|
| 17 |
|
| 18 |
@GetMapping("/call-face-recognition")
|
| 19 |
public String callFaceRecognition() {
|
|
|
|
| 24 |
return "Error calling face-recognition API";
|
| 25 |
}
|
| 26 |
}
|
| 27 |
+
}
|
src/main/java/com/cs102/attendance/service/FastApiCallerService.java
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
package com.cs102.attendance.service;
|
| 2 |
|
| 3 |
import java.net.URI;
|
|
@@ -5,9 +6,12 @@ import java.net.http.HttpClient;
|
|
| 5 |
import java.net.http.HttpRequest;
|
| 6 |
import java.net.http.HttpResponse;
|
| 7 |
|
|
|
|
|
|
|
| 8 |
import com.fasterxml.jackson.databind.JsonNode;
|
| 9 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 10 |
|
|
|
|
| 11 |
public class FastApiCallerService {
|
| 12 |
|
| 13 |
private static final String FASTAPI_URL = "https://kevansoon-java-facerecognition-endpoint.hf.space/face-recognition";
|
|
|
|
| 1 |
+
// FastApiCallerService.java
|
| 2 |
package com.cs102.attendance.service;
|
| 3 |
|
| 4 |
import java.net.URI;
|
|
|
|
| 6 |
import java.net.http.HttpRequest;
|
| 7 |
import java.net.http.HttpResponse;
|
| 8 |
|
| 9 |
+
import org.springframework.stereotype.Service;
|
| 10 |
+
|
| 11 |
import com.fasterxml.jackson.databind.JsonNode;
|
| 12 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 13 |
|
| 14 |
+
@Service
|
| 15 |
public class FastApiCallerService {
|
| 16 |
|
| 17 |
private static final String FASTAPI_URL = "https://kevansoon-java-facerecognition-endpoint.hf.space/face-recognition";
|