adds express server

This commit is contained in:
Daniel Avila 2023-02-04 20:08:28 -05:00
parent 037a12a282
commit 92860a1bb4
3 changed files with 2869 additions and 17 deletions

2859
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,9 @@
},
"homepage": "https://github.com/danny-avila/rpp2210-mvp#readme",
"dependencies": {
"chatgpt": "^4.1.1",
"dotenv": "^16.0.3",
"mongoose": "^6.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
@ -39,6 +42,7 @@
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-jest": "^27.2.1",
"html-webpack-plugin": "^5.5.0",
"nodemon": "^2.0.20",
"path": "^0.12.7",
"postcss": "^8.4.21",
"postcss-loader": "^7.0.2",

23
server/index.js Normal file
View file

@ -0,0 +1,23 @@
const path = require('path');
const express = require('express');
const app = express();
const port = 3050;
app.use(express.json());
const projectPath = path.join(__dirname, '..');
app.use(express.static(path.join(projectPath, 'public')));
app.get('/', function (req, res) {
console.log(path.join(projectPath, 'public', 'index.html'));
res.sendFile(path.join(projectPath, 'public', 'index.html'));
});
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.
});
app.listen(port, () => {
console.log(`Server listening at http://localhost:${port}`);
});