Created
October 7, 2016 18:15
-
-
Save anonymous/e9714a2f74d8f03a6c3831f110a109ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var path = require('path'); | |
var app = express(); | |
var fs = require('fs'); | |
console.log(__dirname); | |
app.use('/cssFiles', express.static(__dirname + '/assets')); | |
app.get('/', function(req, res) { | |
res.sendFile('index.html', {root: path.join(__dirname, './files')}); | |
}); | |
app.get(/^(.+)$/, function(req,res) { | |
console.log(req.params); | |
try { | |
if(fs.statSync(path.join(__dirname, './files/', req.params[0]+'.html')).isFile()){ | |
res.sendFile(req.params[0]+'.html', {root: path.join(__dirname, './files')}); | |
} | |
} catch(err) { | |
console.log(err); | |
res.sendFile('404.html', {root: path.join(__dirname, './files')}); | |
} | |
}); | |
app.listen(1337, function() { | |
console.log('listening at 1337'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment