0

Hello I have got to configure an express app in an architecture that look like this:

![my architecture][1]


Build
Core/pulse.core/assets/styles/global.css
app.js
Express_app
  views/home.jade
  controller/routes.js
node_modules

my app.js looks like this:

var express = require('express'),
    http = require('http'),
    fs = require('fs'),
    path = require('path');

var app = express();

html_templates = __dirname + '/Express_app';

app.set('views', html_templates + '/views');
app.set('view engine', 'jade');

app.use("/Core", express.static(__dirname + 'Core/Pulse.Core/Assets/Styles/'));


app.listen(3000, function () {
    console.log("express has started on port 3000");
});

require('./Express_app/controller/routes.js')(app);

in my home.jade file, i have:

link(rel="stylesheet", href=levelarbo+"../../Core/Pulse.Core/Assets/Styles/global.css")

My html is loading fine, however, i am getting a 404 for my css file, please help. I have been stuck on this for hours :(

4
  • Try app.use("/Core", express.static(__dirname + '/Core')); Commented Sep 2, 2014 at 7:05
  • i still get a 404 on this: localhost:3000/Core/Pulse.Core/Assets/Styles/global.css :( Commented Sep 2, 2014 at 7:08
  • Make sure it's not a case sensitivity issue... check the casing of the path in the URL matches the file system. Commented Sep 2, 2014 at 7:14
  • You are absolutely right !! got it working - accepted answer :) cheers Commented Sep 2, 2014 at 7:18

1 Answer 1

1
app.use("/Core", express.static(__dirname + 'Core/Pulse.Core/Assets/Styles/'));

Should be (note the location of the /)...

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

The casing in the URL should match the casing in the file system. If the actual path is Core/pulse.core/assets/styles/global.css, the jade file should read...

link(rel="stylesheet", href=levelarbo+"../../Core/pulse.core/assets/styles/global.css")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.