aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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+".");