Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed AssassinPanel to call the fileserver controller instead of in…

…dependent file handling
  • Loading branch information...
commit 5285520ddf827768b3470fe6b8c8fd08c983ecc9 1 parent 09ca8ae
@tsjamm tsjamm authored
View
2  assassinPanel/index_style.css
@@ -83,7 +83,7 @@ width: 71%;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
-margin-bottom: 10px;
+margin-bottom: 30px;
padding: 20px;
box-shadow: 0px 0px 130px 0px white;
border-radius: 70px;
View
1  config/routes.txt
@@ -9,3 +9,4 @@ GET /favicon.ico proxy
GET /proxy/getURL proxy
GET /reg/[a-zA-Z0-9]*/test testReg
GET /assassinPanel/[a-zA-Z0-9_./]* assassinPanel
+GET /[a-zA-Z0-9_./]* fileserver
View
48 controllers/assassinPanel.js
@@ -6,58 +6,16 @@
*/
-var url = require('url');
-var fs = require('fs');
-var logger = require('../system/logger');
-var respond = require('./respond');
+var fileserver = require('./fileserver');
+
-var filetypemap = {};
-ReadFileTypeList();
-function ReadFileTypeList()
-{
- var data = fs.readFileSync('./config/filetypelist.txt');
- if(data == null)
- {
- logger.write('Error in Reading filetypelist.txt:\n');
- }
- else
- {
- var listentries = data.toString().split('\n');
-
- for(row in listentries)
- {
- row = listentries[row];
- filetypemap[row.split('\t')[0].split('.')[1]] = row.split('\t')[1];
- }
- }
-}
function invoke(req,res)
{
//First need to check of user validation credentials.
//If valid user, then show home page
//else redirect to login index page
- var reqDetails = url.parse(req.url);
- logger.write("Request Details To AssassinPanel: "+JSON.stringify(reqDetails));
- var filepath =reqDetails.pathname;
- if(filepath=='/assassinPanel/')
- filepath = '/assassinPanel/index.html';
- fs.readFile("."+filepath,function(err,data){
- if(err)
- {
- respond.createResponse(res,404,null,'Requested Resourse is not found on the server. Please Check the URL');
- logger.write('Error in Reading File or Missing File from AssassinPanel:\n'+err+'\n');
- }
- else
- {
- var extension = filepath.split('.').pop();
- logger.write('File Extension is = '+extension);
- var contenttype = filetypemap[extension];
- respond.createResponse(res,200,contenttype,data);
- logger.write('Written File Contents to Response with content-type: '+contenttype+'\n');
-
- }
- });
+ fileserver.serveFile(req,res,'assassinPanel');
}
exports.invoke = invoke;
View
7 controllers/fileserver.js
@@ -27,14 +27,17 @@ function ReadFileTypeList()
}
-function serveFile(req,res)
+function serveFile(req,res,defaultDir)
{
var reqDetails = url.parse(req.url);
logger.write("Request Details: "+JSON.stringify(reqDetails));
var filepath =reqDetails.pathname;
if(filepath=='/')
filepath = '/index.html';
- fs.readFile("./public"+filepath,function(err,data){
+ //if(defaultDir==null ||defaultDir==undefined)
+ // defaultDir='/public';
+ //fs.readFile("."+defaultDir+filepath,function(err,data){
+ fs.readFile("."+filepath,function(err,data){
if(err)
{
respond.createResponse(res,404,null,'Requested Resourse is not found on the server. Please Check the URL');
Please sign in to comment.
Something went wrong with that request. Please try again.