From 7be31fd57ea61d523cafa9bbf950a326afd11968 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Wed, 30 Jan 2013 03:05:31 -0500 Subject: [PATCH] move output to browser (from inspector) --- index.html | 45 ++++++++++++++++++++++++++++++++++++++------- publish-my-session.coffee | 20 +++++++++++++++----- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index daa26ae..d540026 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,38 @@ - - + + + + Remote Terminal Viewer + + + + + + + + diff --git a/publish-my-session.coffee b/publish-my-session.coffee index bd2cd30..fec3467 100644 --- a/publish-my-session.coffee +++ b/publish-my-session.coffee @@ -1,10 +1,20 @@ handler = (req, res) -> - fs.readFile __dirname + '/index.html', (err, data) -> - if err - res.writeHead(500) - return res.end('Error loading index.html') + err = (req, res) -> + res.writeHead(404, 'Content-Type': 'text/plain') + return res.end("Error loading #{req.url}") + switch req.url + when '/', '/index.html' + filename = __dirname + '/index.html' + type = 'text/html' + when '/jquery.js' + filename = '/usr/share/javascript/jquery/jquery.min.js' + type = 'text/javascript' + else + return err req, res + fs.readFile filename, (err, data) -> + return err req, res if err - res.writeHead(200) + res.writeHead(200, 'Content-Type': type) res.end(data) app = require('http').createServer(handler) -- 1.7.10.4