Skip to content

Instantly share code, notes, and snippets.

@paulfryzel
Last active December 15, 2015 15:59
Show Gist options
  • Save paulfryzel/5285940 to your computer and use it in GitHub Desktop.
Save paulfryzel/5285940 to your computer and use it in GitHub Desktop.
var http = require('http'),
fs = require('fs');
http.createServer(function (req, res) {
var user = 'paulfryzel';
var path = '/Users/' + user + '/Desktop/newapp/';
if (req.url === '/css/img/BG.png') {
fs.readFile(path + 'css/img/BG.png', function (error, content) {
if (error) {
res.writeHead(500);
res.end(content, 'utf-8');
} else {
res.writeHead(200, {
'Content-Type': 'image/png'
});
res.end(content, 'utf-8');
}
});
}
fs.readFile(path + 'index.html', function (error, content) {
if (error) {
res.writeHead(500);
res.end(content, 'utf-8');
} else {
res.writeHead(200, {
'Content-Type': 'text/html'
});
res.end(content, 'utf-8');
}
});
}).listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment