-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (23 loc) · 736 Bytes
/
Copy pathindex.js
File metadata and controls
26 lines (23 loc) · 736 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
const express = require('express')
const route = require('./route/route');
const mongoose = require('mongoose');
const uri = "mongodb://localhost:27017/course";
const port = 8000;
const app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: false })) // for parsing application/x-www-form-urlencoded
//app.set('view engine', 'ejs')
//app.set("views", "./views");
app.use(express.static(__dirname + '/public'));
mongoose.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then((db) => {
console.log(`Connect database ${uri}`)
}).catch((err) => {
console.log("Connect error!")
})
route(app)
app.listen(port, () => {
console.log(`Server started at http://localhost:${port}`)
})