Skip to content

Commit f3a79c0

Browse files
committed
add java ssl and cors and connect it - java process mediates between express and unreal
1 parent c1b458d commit f3a79c0

File tree

5 files changed

+55
-31
lines changed

5 files changed

+55
-31
lines changed

interactive-ai-holograms/python-realtimespeech-selectai/src/AIHoloRest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def doTTSAndAudio2Face(latest_answer, latest_question):
179179
}
180180
payload = {
181181
"a2f_player": "/World/audio2face/Player",
182-
"dir_path": "C:/aiholo-app/python-realtimespeech-selectai"
182+
"dir_path": "C:/Users/opc/src/github.com/paulparkinson/oracle-ai-for-sustainable-dev/interactive-ai-holograms/python-realtimespeech-selectai"
183183
}
184184
response = requests.post(url, json=payload, headers=headers)
185185
if response.status_code == 200:
@@ -205,8 +205,8 @@ def handleContainsLogic(cummulative_result, logic_array):
205205
latest_action = item["containsWord"]
206206
return True
207207

208-
SSL_CERT_FILE = r"C:\aiholo-app\localhost.pem" # Path to your certificate
209-
SSL_KEY_FILE = r"C:\aiholo-app\localhost-key.pem" # Path to your private key
208+
SSL_CERT_FILE = r"C:\Users\opc\src\github.com\paulparkinson\oracle-ai-for-sustainable-dev\interactive-ai-holograms\localhost.pem" # Path to your certificate
209+
SSL_KEY_FILE = r"C:\Users\opc\src\github.com\paulparkinson\oracle-ai-for-sustainable-dev\interactive-ai-holograms\localhost-key.pem" # Path to your private key
210210

211211

212212
async def handle_request(request):

interactive-ai-holograms/react-client/react-client/src/App.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,35 @@ function App() {
8686

8787
console.log("handleCallSelectAI question:", question);
8888
const url = `https://130.61.51.75:8443/data?question=${encodeURIComponent(question)}`;
89+
const urlJava = `https://130.61.51.75:8444/echo/set?value=question`;
8990
console.log("handleCallSelectAI url:", url);
9091
setIsLoading(true);
9192

9293
try {
93-
const response = await fetch(url, {
94+
// const response = await fetch(url, {
95+
// method: "GET",
96+
// headers: { Accept: "application/json" },
97+
// });
98+
99+
// if (!response.ok) {
100+
// throw new Error(`HTTP error! Status: ${response.status}`);
101+
// }
102+
// const data = await response.json();
103+
104+
105+
const responseUnreal = await fetch(urlJava, {
94106
method: "GET",
95107
headers: { Accept: "application/json" },
96108
});
97109

98-
if (!response.ok) {
99-
throw new Error(`HTTP error! Status: ${response.status}`);
110+
if (!responseUnreal.ok) {
111+
throw new Error(`HTTP error! Status: ${responseUnreal.status}`);
100112
}
113+
const data2 = await responseUnreal; //currently just thrown away
101114

102-
const data = await response.json();
103-
setAiResponse(JSON.stringify(data, null, 2));
115+
116+
117+
setAiResponse(JSON.stringify(data2, null, 2));
104118
} catch (error) {
105119
console.error("Error fetching AI data:", error.message);
106120
setAiResponse(`Error: ${error.message}`);
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,22 @@
11
package oracleai;
22

3-
4-
import com.oracle.bmc.aivision.model.FaceDetectionFeature;
5-
import oracleai.services.OracleVisionAI;
6-
import org.springframework.stereotype.Controller;
7-
import org.springframework.ui.Model;
8-
import org.springframework.web.bind.annotation.PostMapping;
9-
import org.springframework.web.bind.annotation.RequestMapping;
10-
import org.springframework.web.bind.annotation.RequestParam;
11-
12-
import oracleai.services.ORDSCalls;
13-
import org.springframework.stereotype.Controller;
14-
import org.springframework.ui.Model;
153
import org.springframework.web.bind.annotation.*;
16-
import org.springframework.web.multipart.MultipartFile;
174

18-
@Controller
5+
@RestController
196
@RequestMapping("/echo")
207
public class EchoController {
21-
String theValue;
8+
private String theValue = "init";
229

2310
@GetMapping("/set")
24-
public String echo(String value) {
11+
public String setValue(@RequestParam("value") String value) {
2512
theValue = value;
26-
System.out.println("EchoController set:" + theValue);
27-
return "set successfully:" + theValue;
13+
System.out.println("EchoController set: " + theValue);
14+
return "set successfully: " + theValue;
2815
}
2916

3017
@GetMapping("/get")
31-
public String echo() {
32-
System.out.println("EchoController get:" + theValue);
18+
public String getValue() {
19+
System.out.println("EchoController get: " + theValue);
3320
return theValue;
3421
}
35-
36-
}
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package oracleai;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.web.servlet.config.annotation.CorsRegistry;
6+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7+
8+
@Configuration
9+
public class WebConfig implements WebMvcConfigurer {
10+
@Override
11+
public void addCorsMappings(CorsRegistry registry) {
12+
registry.addMapping("/**") // This will apply to all routes
13+
.allowedOrigins("https://130.61.51.75:4884") // Allow this origin
14+
.allowedMethods("GET", "POST", "PUT", "DELETE") // Allowed methods
15+
.allowedHeaders("*") // Allowed headers
16+
.allowCredentials(true); // Allow credentials
17+
}
18+
}

java-ai/src/main/resources/application.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@ logging:
2828
org.springframework.web.cors: DEBUG
2929
server:
3030
tomcat:
31-
max-swallow-size: 200MB
31+
max-swallow-size: 200MB
32+
port: 8444
33+
ssl:
34+
key-store-type: PKCS12
35+
key-store: classpath:keystore.p12
36+
key-store-password: Welcome1
37+
key-alias: springboot

0 commit comments

Comments
 (0)