How to make the node identify the path from the root of the request?

2

You're like this:

<link rel="stylesheet" href="http://localhost/node/softmon/css/style.css" type="css">

If I put it this way:

<link rel="stylesheet" href="/css/style.css" type="css">

does not work.

I use this to display the page ***http://localhost:3000***

app.js

var app = require('express')(),
http = require('http').Server(app),
io = require('socket.io')(http),
dbasy = require('./node_modules/dbasy/dbasy.js'),
$ = require('cheerio'),
jsdom = require("jsdom");

app.get('/', function(req, res) {
    res.sendFile(__dirname + '/index.htm');
});
io.on('connection', function(socket) {
    socket.on('operacoes', function(data) {
        console.log()
    }); 
    socket.on('disconnect', function () {
        console.log('Desconetado.');
    });
});
http.listen(1589, function(){
    console.log('Servidor iniciado.');
});

How to make the node identify the path from the root of the request?

    
asked by anonymous 01.12.2014 / 15:31

1 answer

1

You must define how static files are. Add this to index.js :

app.use(express.static(__dirname + '/node/softmon/'));

Assuming that the folder where you have index.js has a subfolder /node/ .

    
01.12.2014 / 18:12