Created
April 20, 2017 00:43
-
-
Save yoshuawuyts/288173c43849f648597bd2e03bdf358e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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