-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
50 lines (37 loc) · 1.21 KB
/
app.js
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
50
const express = require('express');
var app = express();
var port = process.env.PORT || 3000;
var bodyParser = require('body-parser');
const say = require('say')
const path = require('path');
var mongoose = require('mongoose');
var Users = require('./models/users');
mongoose.connect('mongodb+srv://sadh:[email protected]/test?retryWrites=true', { useNewUrlParser: true });
mongoose.connection.on("error", function (err) {
console.log("Could not connect to mongo server!");
return console.log(err);
});
app.use(bodyParser.json({ limit: '50mb' }));
app.use(express.static(path.join(__dirname, 'public')));
console.log(`app running on port ${port}`);
app.get("/save/:name", (req, res) => {
var name = req.params.name;
var _user = new Users({
"name": name,
"time": String(new Date())
});
_user.save((err) => {
console.log(`saved`);
res.send(name);
});
});
app.get("/camera",(req,res)=>{
res.sendFile(path.join(__dirname ,'public','camera.html'));
});
app.get("/results",(req,res)=>{
res.sendFile(path.join(__dirname ,'public','lb.html'));
});
app.get("/ppt",(req,res)=>{
res.sendFile(path.join(__dirname ,'public','ppt.html'));
});
app.listen(port);