Skip to content

Instantly share code, notes, and snippets.

@antimatter15
Created August 24, 2014 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antimatter15/2dfeb602e1f98d7f1989 to your computer and use it in GitHub Desktop.
Save antimatter15/2dfeb602e1f98d7f1989 to your computer and use it in GitHub Desktop.
FOAR SCOTT FRUM BOXXY
var http = require('http'),
path = require('path'),
fs = require('fs');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
if(req.method.toUpperCase() == "POST"){
var file = path.normalize(req.url);
console.log(file);
req.pipe(fs.createWriteStream(__dirname + file))
res.end("fin.\n");
}else{
res.end("I'm sorry, but we only accept postcards from Paris.\n");
}
}).listen(14361, '127.0.0.1');
function fafnir(name, data){
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://127.0.0.1:14361/' + name, true);
xhr.send(data);
}
console.log(fafnir.toString());
console.log('_____________________________________________')
// Chapter 8 Section 8 of LoTR Volume 3: The Extended Cut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment