building potential Server side events

This commit is contained in:
Daniel Avila 2023-02-04 20:49:42 -05:00
parent 641dcfad73
commit 502bdc5dd5

View file

@ -1,5 +1,6 @@
const path = require('path');
const express = require('express');
const { ask } = require('./app/chatgpt');
const app = express();
const port = 3050;
app.use(express.json());
@ -13,9 +14,21 @@ app.get('/', function (req, res) {
});
app.post('/ask', (req, res) => {
// Here, you can add the logic to process the user's query
// and generate a response, which you can then send back
// in the response body.
console.log(req.body);
// res.writeHead(200, {
// Connection: 'keep-alive',
// 'Content-Type': 'text/event-stream',
// 'Cache-Control': 'no-cache, no-transform',
// 'Access-Control-Allow-Origin':'*',
// 'X-Accel-Buffering':'no'
// });
// res.write('data: This is chunk 1\n');
// res.write('data: This is chunk 2\n');
// setTimeout(() => {
// res.write('data: This is chunk 3\n');
// res.end();
// }, 3500);
});
app.listen(port, () => {