-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
32 lines (23 loc) · 768 Bytes
/
app.js
File metadata and controls
32 lines (23 loc) · 768 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
30
31
32
const express = require('express')
const path = require('path');
const bodyParser = require('body-parser');
const controller = require('./controller/controller');
const api_routes = require('./routes/api_routes');
const app = express()
app.use(express.static(path.join(__dirname, 'public', 'copy-me')));
app.use(bodyParser.json());
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
//API routes
app.use('/api', api_routes);
// UI route
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname));
});
controller.begin();
app.listen(3000, function() {
console.log("Running on port 3000");
});