Last active
August 29, 2015 14:17
-
-
Save romyilano/efa89c4655f0e83614eb 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 h = require('virtual-dom/h'); | |
var str = require('virtual-dom-stringify'); | |
var http = require('http'); | |
var fs = require('fs'); | |
var ecstatic = require('ecstatic'); | |
var st = ecstatic(__dirname); | |
var server = http.createServer(function (req, res) { | |
if (req.url === '/') { | |
fs.readdir(__dirname + '/images', onfiles); | |
} | |
else st(req, res); | |
function onfiles (err, files) { | |
var tree = h('div#content', [ | |
h('h1', 'wow hello'), | |
h('div.gallery', files.map(function (x) { | |
return h('div', [ | |
h('img', { | |
src: 'images/' + x, | |
height: 128 | |
}) | |
]); | |
})) | |
]); | |
res.end(str(tree)); | |
} | |
}); | |
server.listen(6004); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
learning the ultra low down basics of node
thanks substack!