-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (23 loc) · 743 Bytes
/
app.js
File metadata and controls
34 lines (23 loc) · 743 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
33
34
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var urlencodedParser = bodyParser.urlencoded({extended:false});
var app = express();
app.use(express.static('public'));
//mongoose.connect('mongodb://localhost/mydb');
var personSchema = mongoose.Schema({
name : String,
age : Number,
nationality : String
});
var Person = mongoose.model("Person", personSchema);
app.get('/', function(req, res){
res.sendFile(__dirname+"/views/"+"index.html");
});
app.post('/',function(req, res){
});
var server = app.listen(8000, function(){
var host = server.address().address;
var port = server.address().port;
console.log('server running at http://%s:%s',host, port);
});