diff options
Diffstat (limited to 'pnhandler.js')
-rw-r--r-- | pnhandler.js | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/pnhandler.js b/pnhandler.js index 4123049..dba03db 100644 --- a/pnhandler.js +++ b/pnhandler.js @@ -5,41 +5,90 @@ */ var util = require('util'); +var querystring = require('querystring'); -function noop(query, res) { +function noop(query, reqdata, res) { util.log('[pnhandler] handling ' + query.pathname + ', ok who the fuck is messing with us?'); res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(); } -function register(query, res) { +function register(query, reqdata, res) { util.log('[pnhandler] handling ' + query.pathname); res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(); } -function login(query, res) { +function login(query, reqdata, res) { util.log('[pnhandler] handling ' + query.pathname); res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(); } -function poll(query, res) { +function poll(query, reqdata, res) { util.log('[pnhandler] handling ' + query.pathname); res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(); } -function upload(query, res) { +function upload(query, reqdata, res) { util.log('[pnhandler] handling ' + query.pathname); + res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(); } +function hello(query, reqdata, res) { + util.log('[pnhandler] handling ' + query.pathname); + + var body = + '<!DOCTYPE html>\n' + + '<html>\n' + + '<head>\n' + + '<title>Hello</title>\n' + + '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n' + + '</head>\n' + + '<body>\n' + + '<form action="/hellores" method="post">\n' + + '<textarea name="text" rows="20" cols="60"></textarea><br />\n' + + '<input type="submit" value="Submit text" />\n' + + '</form>\n' + + '</body>\n' + + '</html>\n'; + + res.writeHead(200, {'Content-Type': 'text/html'}); + res.write(body); + res.end(); +} + +function hellores(query, reqdata, res) { + util.log('[pnhandler] handling ' + query.pathname); + util.log('[pnhandler] hello recv:\n' + querystring.parse(reqdata).text); + + var body = + '<!DOCTYPE html>\n' + + '<html>\n' + + '<head>\n' + + '<title>Hello Response</title>\n' + + '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n' + + '</head>\n' + + '<body>\n' + + '<p>You requested/sent:<br /></p>' + + querystring.parse(reqdata).text + + '</body>\n' + + '</html>\n'; + + res.writeHead(200, {'Content-Type': 'text/html'}); + res.write(body); + res.end(); +} + exports.noop = noop; exports.register = register; exports.login = login; exports.poll = poll; exports.upload = upload; +exports.hello = hello; +exports.hellores = hellores; |