Skip to content

Instantly share code, notes, and snippets.

@uzumaki-narut0
Last active May 29, 2017 20:27
Show Gist options
  • Save uzumaki-narut0/4824e7d170902bdd77ab6660ffc1bedd to your computer and use it in GitHub Desktop.
Save uzumaki-narut0/4824e7d170902bdd77ab6660ffc1bedd to your computer and use it in GitHub Desktop.
var express = require('express');
var path = require('path');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http); //socket server which integrates with (mounts on) http server
var hbs = require('express-handlebars');
var handlebars = require('handlebars');
var helpers = require('handlebars-form-helpers').register(handlebars);
//app.use(express.static('public'));
app.use(express.static(__dirname + '/public'));
var portnumber = process.env.PORT || 8080;
app.engine('hbs',hbs({extname: 'hbs', defaultLayout: 'layout', layoutsDir: __dirname+'/views'}));//first argument is engine name which can be anything
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
app.get('/', function(req, res){
res.render('home_page');
});
app.get('/:id/:playas',function(req,res){
console.log(req.params);
res.render('index', {id: req.params.id,
playas: req.params.playas
});
//res.status(200).send(html);
})
http.listen(portnumber, function(){
console.log('listening on *:8080');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment