Update index.js
Browse files
index.js
CHANGED
|
@@ -134,12 +134,16 @@ app.use((req, res, next) => {
|
|
| 134 |
|
| 135 |
app.post('/', async (req, res) => {
|
| 136 |
const { content, user, prompt, webSearchMode } = req.body;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
try {
|
| 138 |
const result = await blackboxChat(content, user, prompt, webSearchMode);
|
| 139 |
res.json({ result });
|
| 140 |
} catch (error) {
|
| 141 |
console.error("Error:", error.message);
|
| 142 |
-
res.status(
|
| 143 |
}
|
| 144 |
});
|
| 145 |
|
|
@@ -169,6 +173,6 @@ app.use((req, res) => {
|
|
| 169 |
res.sendFile(path.join(__dirname, 'index.html'));
|
| 170 |
});
|
| 171 |
|
| 172 |
-
app.listen(
|
| 173 |
console.log(`Server is listening at port:${port}`);
|
| 174 |
});
|
|
|
|
| 134 |
|
| 135 |
app.post('/', async (req, res) => {
|
| 136 |
const { content, user, prompt, webSearchMode } = req.body;
|
| 137 |
+
if (!content) {
|
| 138 |
+
return res.status(400).json({ error: "Content is required" });
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
try {
|
| 142 |
const result = await blackboxChat(content, user, prompt, webSearchMode);
|
| 143 |
res.json({ result });
|
| 144 |
} catch (error) {
|
| 145 |
console.error("Error:", error.message);
|
| 146 |
+
res.status(500).json({ error: "Internal server error" });
|
| 147 |
}
|
| 148 |
});
|
| 149 |
|
|
|
|
| 173 |
res.sendFile(path.join(__dirname, 'index.html'));
|
| 174 |
});
|
| 175 |
|
| 176 |
+
app.listen(port, () => {
|
| 177 |
console.log(`Server is listening at port:${port}`);
|
| 178 |
});
|