-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (30 loc) · 814 Bytes
/
index.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
var express = require('express'),
app = express();
bodyParser = require('body-parser');
_ = require("underscore");
mongoose = require('mongoose');
Test = require('./models/test_model'); //require your model in your server
mongoose.connect('mongodb://localhost/###name-of-your-database-goes-here###');
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static(__dirname + '/public'));
var users = [
{
id: 1,
name: 'Bob',
username: 'bobiscool'
},
{
id: 2,
name: 'Julie',
username: 'julierocks'
}
];
app.get('/', function(req, res) {
res.sendFile(__dirname + '/public/views/index.html');
});
app.get('/users', function(req, res) {
res.json(users);
});
app.listen(3000, function() {
console.log('server started on localhost:3000');
});