Hi All,

Newbie here so I'll do my best.  I've spent the last two says trying to 
figure out how to link my index.html page to my CSS file.  There are a 
couple of "Examples" out there but none of them worked for me, and of 
course others have posted comments back as to why their approach is the 
wrong way etc.   So I have no idea what is the best practice is to order up 
a CSS file....and get it to work!  I do want to learn to do it the right 
way but I need some guidance.

Here is my starting file below.  I guess my question is two part.  1) How 
do I make my index.html page link to my CSS (*css/style.css*) file?  2) 
Should I be using a pre-processor CSS engine like Stylus/Less?...and if so 
is there a good example I can download and learn from?  The posts out there 
don't seem to be helping me at the moment.

Environment:
Ubuntu Server 11.1
Node 0.6.15



// Require Dependencies
var  app    = require('http').createServer(handler)
, fs   = require('fs')
, io   = require('socket.io').listen(app);
 
// Server on ( localhost:8000 )
app.listen(8000);
 
// Load up index.html page
function handler(req, res) {

  fs.readFile(__dirname + '/index.html', function(err, data) {
    if(err) {
      console.log(err);
      res.writeHead(500);
      return res.end('Error loading index.html');
    }
    else {
            res.writeHead(200, { 'Content-Type': 'text/html' });
            res.end(data, 'utf-8');
        }
  });
}

The one thought that does come to mind, architecturally speaking, there 
must be a way to serve the CSS file once and have the file referenced from 
cache instead of being sent on every hit. 

Thanks in advance!
Flex

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to