Skip to content

Instantly share code, notes, and snippets.

@yoshuawuyts
Created April 20, 2017 00:43
Show Gist options
  • Save yoshuawuyts/288173c43849f648597bd2e03bdf358e to your computer and use it in GitHub Desktop.
Save yoshuawuyts/288173c43849f648597bd2e03bdf358e to your computer and use it in GitHub Desktop.
var pathname = require('pathname-match')
var http = require('http')
// this should point to your choo app, which should export if required,
// and mount itself if it's the root module. e.g.
//
// if (module.parent) module.exports = app
// else app.mount('body')
var app = require('./my-app')
var server = http.createServer(function (req, res) {
var url = pathname(req.url)
var html = app.toString(url)
res.writeHead(200, {
'content-type': 'text/html',
'content-length': html.length
})
res.end(html)
})
server.listen(process.env.PORT || 8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment