I have a view in my Node app, but the external CSS file does not link
properly. How do I allow the server I created to send that resource?
Im very new to this so even a hardcoded static solution would be good.

Here is the JS code that I run in Node:

var http = require('http');
var url = require('url');
var fs = require('fs');

var newPostFormHTML = fs.readFileSync('views/home.html');

function renderNewPostForm(request, response) {
        response.writeHead(200, {
                'Content-type':'text/html; charset=utf-8'
        });

        response.end(newPostFormHTML);
}

function render404(request, response) {
        response.writeHead(404);
        response.end('404 File not found.');
}

var server = http.createServer(function(request, response) {
        var newPostFormRegex = new RegExp('^/home/?$');
        var pathname = url.parse(request.url).pathname;
        if(newPostFormRegex.test(pathname)) {
                renderNewPostForm(request, response);
        }
        else {
                render404(request, response);
        }
});

server.listen(8000);

console.log('listening on http://127.0.0.1:8000');

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to