Expressworks Stylish CSS question

Expressworks Stylish CSS question
0.0 0

#1

Here’s the code I have so far:

var express = require('express');
var http = require('http');
var app = express();

app.use(require('stylus').middleware(
  { src: __dirname + '/public' }
));

app.post(process.argv[3], function (req, res) {
  var value = req.body.str.split('').reverse().join('');
  console.log(value);
  res.end(value);
});

http.createServer(app).listen(process.argv[2]);

The console.log statement is printing:

Error
Cannot GET /main.css

I think that’s happening because the .styl file isn’t getting translated into a .css file properly. I tried messing with this line:

app.use(require('stylus').middleware(
  { src: __dirname + '/public' }
));

using stuff like process.argv[3] under the assumption that the parameter getting passed in by expressworks is part of the solution but I still kept getting this result. Any help is appreciated, I’ve gotten 4-5 exercises done since my last question but this one has me stumped again.

P.S. I was looking up examples online and they all match the above line so that’s why I wrote it back as that after testing other options.


#2

Do you have a static files route?


#3

I don’t. I tried adding this line to the code after reading the article you linked:

app.use(express.static('public'));

I’m still getting the same error though.