node.js - Using directory (for images links etc) in Openshift (nodejs application) -


i have webpage have hosted using node application on openshift. here http://nodejs-volition.rhcloud.com/

my question simple (although haven't found else asking it). how refer other files in directory contains index.html

for instance use image in directory in index. current html image is

<img src="$openshift_repo_dir/images/1416870991752.jpg" alt="spark core"> 

i have tried using "images/1416870991752.jpg". have same problem linking other html files in directory? doing wrong? please help?

as corey112358 alludes below key in host using nodejs server must defined. application has server file, rather creating new server must modify existing one. i've done now, there 2 changes make server.js file.

the 1st change modification of cache. should this...

self.zcache['index.html'] = fs.readfilesync('./index.html'); self.zcache['page2.html'] = fs.readfilesync('./page2.html'); self.zcache['sparkcoredark.jpg'] = fs.readfilesync('./sparkcoredark.jpg'); 

the first line included next 2 added me include html page , image.

the second step modify self.createroutes section of server.js file below (asciimo image included default).

self.createroutes = function() { self.routes = { };

    self.routes['/asciimo'] = function(req, res) {         var link = "http://i.imgur.com/kmbjb.png";         res.send("<html><body><img src='" + link + "'></body></html>");     };      self.routes['/'] = function(req, res) {         res.setheader('content-type', 'text/html');         res.send(self.cache_get('index.html') );     };     self.routes['/page2.html'] = function(req, res) {         res.setheader('content-type', 'text/html');         res.send(self.cache_get('page2.html') );     };     self.routes['/sparkcoredark.jpg'] = function(req, res) {         res.setheader('content-type', 'image/jpg');         res.send(self.cache_get('sparkcoredark.jpg') );      }; }; 

hope helps out else struggling issue. coreyfibonacci


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -