aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <hallo@tomsmeding.nl>2015-04-21 22:10:33 +0200
committertomsmeding <hallo@tomsmeding.nl>2015-04-21 22:10:33 +0200
commite6b0788d5cd47574865967815b461b90e67d0a53 (patch)
tree89660d9e612d9c611d996ee0bce35c9a37469c56
parentec7754aa85d8a1c2a0165f995e9db1a04493747f (diff)
Fix css request http thingamagick
-rwxr-xr-xchatserver.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/chatserver.js b/chatserver.js
index 00ca0f1..a263d62 100755
--- a/chatserver.js
+++ b/chatserver.js
@@ -159,7 +159,14 @@ try{
}
http.createServer(function(req,res){
- res.writeHead(200,{"Content-Type":"text/html"});
- res.end(pagehtml);
+ if(req.url=="/"){
+ res.writeHead(200,{"Content-Type":"text/html"});
+ res.end(pagehtml);
+ } else if(!/\/\./.test(req.url)){
+ var url=req.url.slice(1);
+ if(url.indexOf("?")!=-1)url=url.slice(0,url.indexOf("?"));
+ try{res.end(fs.readFileSync(url).toString());}
+ catch(e){res.end("error");}
+ }
}).listen(HTTPPORT);
console.log("HTTP server started on port "+HTTPPORT+".");