Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 17th, 2012  |  syntax: JavaScript  |  size: 0.51 KB  |  views: 116  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. var server = require("http").createServer(function (request, response) {
  2.   var data = "";
  3.  
  4.   request.on("data", function(data_) {
  5.     data += data_;
  6.   }).on("end", function() {
  7.     if (data) {
  8.       var text = require("querystring").parse(data).text;
  9.       // text === "stuff"
  10.       response.writeHead(200, {
  11.           'Content-Type': 'audio/mp3',
  12.           'Content-Disposition': 'attachment; filename="tts.mp3"'
  13.       });
  14.     } else {
  15.       response.end('No text to convert.');
  16.     }
  17.   });
  18. }).listen(8080);
clone this paste RAW Paste Data