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
37 lines (30 loc) · 1.11 KB
/
server.js
File metadata and controls
37 lines (30 loc) · 1.11 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
const express = require('express');
const app = express();
const path = require('path');
const database = express();
const http = require('http');
const databaseServer = http.createServer(database);
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:4000')
}); //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)
database.get('/', (req, res) => {
console.log('DATABSE GET IS WORKING')
res.send('GET DATABASE IS WORKING')
})
databaseServer.listen(9000, () => {
console.log('listening at http://localhost:8080');
});
module.exports = databaseServer;