-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (21 loc) 路 796 Bytes
/
Copy pathindex.js
File metadata and controls
25 lines (21 loc) 路 796 Bytes
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
const express = require('express');
const cors = require('cors');
const axios = require('axios');
const app = express();
const PORT = process.env.PORT || 4000;
app.use(cors());
app.use(express.json());
// Example endpoint that relays to local Langflow/Ollama stack
app.post('/api/ask', async (req, res) => {
try {
const { question } = req.body;
const response = await axios.post('http://localhost:7860/ask', { question }); // Replace with your local Langflow endpoint
res.json({ success: true, answer: response.data });
} catch (error) {
console.error('[Proxy Error]', error.message);
res.status(500).json({ success: false, error: 'Failed to contact local AI engine' });
}
});
app.listen(PORT, () => {
console.log(`馃敟 Proxy server running on port ${PORT}`);
});