Serving custom html pages / routing question

I am running older version of Ghost Blog (0.7.*)

i would like to server a custom html folder when someone goes to myblog.com/customfolder

i am looking at frontend.js which appears to be using regular express routing, and im trying to add something like this:

// adding bitcoin slideshow 
router.use('/customfolder', express.static(__dirname + '/customfolder')); // this doesn't work 

router.get(/customfolder\/$/, function(req,res) {
    console.info("customfolder PATH!!!!!!", __dirname); 
    res.sendFile(path.join(__dirname + '/../../../customfolder/index.html')); // this works 
})

not sure if this is the problem, but when i type /customfolder/mycustumfile.html , it does add a trailing slash (‘/’) to the url.

in any case the server write looks like this:

/mycustomfolder/sub/foo.html/ 404 64.833 ms - -

all i want is to server regular express style files in this folder, so i can host a html presentation

here is my solution. probably not the best?! please let me know if there is a better way.

i am just trying to have a separate html content in a /subpath

router.get(/mycustompath\/$/, function(req,res) {
    res.sendFile(path.join(__dirname + '/../../../mycustompath/index.html')); 
})
router.get(/mycustompath.+/, function(req,res) { // serve any content under mycustompath 
    var filePath = path.join(__dirname + '/../../..' + req.path);
    filePath = filePath.substr(0, filePath.length -1);
    res.sendFile(filePath);
})

Ghost 0.7 is about 3 years old and is not supported in any way. Running out of date software on a public web server is an extremely bad idea and that should be your first concern before trying to figure out how to serve any file at all.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.