forked from jayd74/chef-gpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-backend.js
More file actions
41 lines (34 loc) Β· 1.27 KB
/
test-backend.js
File metadata and controls
41 lines (34 loc) Β· 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Test script to verify ML backend connection
const BACKEND_URL = 'https://chef-gpt-c4sc.onrender.com';
async function testBackend() {
console.log('π§ͺ Testing ML Backend Connection...');
console.log(`π Backend URL: ${BACKEND_URL}`);
console.log(`π§ Environment: ${process.env.NODE_ENV || 'development'}`);
try {
// Test health endpoint
console.log('\n1. Testing health endpoint...');
const healthResponse = await fetch(`${BACKEND_URL}/health`);
const healthData = await healthResponse.json();
console.log('β
Health check:', healthData);
// Test flyer dinner endpoint
console.log('\n2. Testing flyer dinner endpoint...');
const flyerResponse = await fetch(`${BACKEND_URL}/flyer_dinner`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ banner: 'no_frills' }),
});
if (flyerResponse.ok) {
const flyerData = await flyerResponse.json();
console.log('β
Flyer dinner test:', flyerData);
} else {
console.log('β Flyer dinner test failed:', flyerResponse.status);
}
console.log('\nπ Backend connection test completed!');
} catch (error) {
console.error('β Test failed:', error.message);
}
}
// Run the test
testBackend();