Skip to content

Instantly share code, notes, and snippets.

@nikoloza
Last active June 4, 2016 23:49
Show Gist options
  • Save nikoloza/c1700a67c2aa3d999ad4 to your computer and use it in GitHub Desktop.
Save nikoloza/c1700a67c2aa3d999ad4 to your computer and use it in GitHub Desktop.
Use README.md file as a homepage for Express based services
var express = require('express')
var marked = require('marked')
var app = express();
// use README.md file as a homepage
app.get('/', function(req, res) {
res.set('content-type','text/html');
res.send(
'<style>' +
fs.readFileSync('./node_modules/github-markdown-css/github-markdown.css') +
'</style>' +
'<div class="markdown-body">' +
marked(
fs.readFileSync(__dirname + '/README.md', 'utf8');
) +
'</div>'
);
res.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment