-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathadmin.js
More file actions
49 lines (38 loc) · 1.19 KB
/
Copy pathadmin.js
File metadata and controls
49 lines (38 loc) · 1.19 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import dotenv from 'dotenv';
import bodyParser from 'body-parser';
import express from 'express';
import { connect, Schema, model } from 'mongoose';
const app = express();
dotenv.config();
const MONGO_URI = "mongodb+srv://agherakrutik99:[email protected]/Chatbot_questionSet?retryWrites=true&w=majority"
const port = process.env.PORT || 3000;
connect(MONGO_URI, {
userNewUrlParser: true,
userUnifiedTopology : true
}).then(() => {
console.log("YES YEs");
}).catch( err => console.log(err));
const questionSchema = Schema(
{
email : {
type : "String",
require: true
},
question: {
type : "String",
require: true
}
}
);
const Question = model('Question', questionSchema);
app.use('/public', express.static(`${process.cwd()}/public`));
app.use(bodyParser.urlencoded({ extended: false }))
app.get('/', function(req, res) {
res.sendFile(process.cwd() + '/index.html');
console.log(req.body)
});
app.post("/admin", (req,res) => {
res.sendFile(process.cwd() + '/src/views/question.html');
let email = req.body.email;
let questionAsked = req.body.question;
})