forked from FamesStore/scratchProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (24 loc) · 976 Bytes
/
server.js
File metadata and controls
29 lines (24 loc) · 976 Bytes
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
const express = require('express');
const app = express();
const path = require('path');
const database = express();
const http = require('http');
const dbController = require('./controller.js');
const bodyParser = require('body-parser');
//const eventCtrl = require('./controllers/event-controller');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
//app.use(express.static(__dirname +'./index.html')); //serves the index.html
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname +'/index.html'));
})
app.listen(5000, () => {
console.log('listening at http://localhost:5000')
}); //listens on port 3000 -> http://localhost:3000/
app.post("/addUser", dbController.createUser, (req, res) => {
res.sendFile(path.join(__dirname + '/items.html'));
});
app.post("/addItem", dbController.createItem, dbController.getAllItems);
// app.post("/addItem", (req, res) => {
// res.sendFile(path.join(__dirname + '/indexREACT.html'))
// })