forked from you-genie/temp_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
38 lines (32 loc) · 1.02 KB
/
test.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
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var formidable = require('formidable');
var db = mongoose.connection;
db.on('error', console.error);
db.once('open', function() {
console.log("Connected to mongod server");
});
mongoose.connect('mongodb://localhost/testdb');
var Contact = require('./models/contact');
var Photo = require('./models/photo');
app.set('views',__dirname + '/views');
app.set('view engine', 'ejs');
app.engine('html', require('ejs').renderFile);
app.get('/:fname', function(req, res) {
res.render('index', {
fName: req.params.fname
});
});
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
app.use(express.static('public'));
var port = process.env.PORT || 2048;
var router = require('./router')(app, Contact, Photo);
var server = app.listen(port, function(err) {
if(err){
console.error(err);
}
console.log("Express server has started on port " + port)
});