Spaces:
Paused
Paused
const express = require('express') | |
const app = express() | |
const port = 7860 | |
const axios = require('axios') | |
app.get('/', (req, res) => { | |
res.send('Hello World!') | |
}) | |
app.get('/api/test', async (req, res) => { | |
try { | |
res.json({message: "Hello world"}) | |
} catch (error) { | |
res.status(401).json({error: error.message}) | |
} | |
}) | |
const akenoaiModeWeb = async (prompt) => { | |
const payload = { | |
prompt: prompt, | |
bid: "040d0481" | |
}; | |
const url = "https://bot-management-4tozrh7z2a-ue.a.run.app/chat/web"; | |
try { | |
const response = await axios.post(url, payload); | |
return response.data.answer; | |
} catch (error) { | |
if (error.response) { | |
console.error("Response Error:", error.response.status, error.response.data); | |
} else { | |
console.error("Error Message:", error.message); | |
} | |
return "Error occurred!"; | |
} | |
}; | |
app.get('/api/akenoweb', async (req, res) => { | |
try { | |
const query = req.params.query; | |
const output = await akenoaiModeWeb(query); | |
res.json({ message: output }); | |
} catch (error) { | |
res.status(401).json({ error: error.message }); | |
} | |
}); | |
app.listen(port, () => { | |
console.log(`Example app listening on port ${port}`) | |
}) |