Pictures, css... where can I store resources?

The OpenShift forums have been retired.
You can still read and search them, but for help, please post a question on Stack Overflow.

Hi!

I'm new at openshift and i'm triying to figure out where to place my images, css, javascripts.etc...

You can see the deafult html that OPENSHIFT created by me when i get my NODE.JS cartridge.

I modified the index.html to insert an image (<img src="mydolfer_at_same_level_as_index/mypicture.jpg"" />) and i'm not succeding on in.

You can see: http://avbconline-240dots.rhcloud.com/

If I do a find . -name mypicture.jpg at my server (connecting via ssh) i find my images ant app-root/repo. At this folder i can find my index.html, my folder "img", my favicon.ico, etc...

What can I do to make that index.html can use my resources??

Thanks in advance, Regards, Carlos

Add below line into self.initializeServer function from server.js file.

        // serve static assets
        self.app.use(express.static(__dirname));

After that you should be able to serve the static files from images directory.

HTH

It sounds like express's 'static' middleware may be what you're looking for.

I usually configure static routes on the resulting express application object after running var app = express.createServer():

app.use('/public', express.static(__dirname+'/public'));

To quickly add a list of static folders, I add something like this:

['css', 'img', 'js', 'plugin', 'lib'].forEach(function (dir){
    app.use('/'+dir, express.static(__dirname+'/'+dir));
});

This example may come in handy: https://github.com/ryanj/darkslides/blob/master/server.js#L122

Thank you Ryan!!!

It helps me!! It works now!! And now i can use my own css, js, plugins, picts...

:)

Regards, Carlos

from http://avbconline-240dots.rhcloud.com/

<img alt="AVBC logo" src="data/img/Marca_AVBC.jpg">

I don't think you have "data/img/Marca_AVBC.jpg"