Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Build a Simple Dynamic Site with Node.js Handling Routes in Node.js Handling Routes Review

who do i ask for help?

I am new to learning all of this. none of this is making any sense to me, so i have to just rely on luck to move forward? what is this? i just have to sit here until another student says something? i will succeed like this? i will be successful in this field when i can’t even get help?

routes.js
function root(request, response) {
    if(request.url == "/") {
        response.writeHead(200, {'Content-type': "text/plain"});
        response.end("Home\n");
    }
}

function contact(request, response) {
    if(request.url == "/contact") {
        response.writeHead(200, {'Content-type': "text/plain"});
        response.end("Contact\n");
    }
}

// Import any necessary modules if required

function about(request, response) {
    if (request.url == "/about") {
        response.writeHead(200, { 'Content-type': "text/plain" });
        response.end("About\n");
    }
}

module.exports = {
    about: about,
    // You can add other route functions here if needed
};


module.exports.root = root;
module.exports.contact = contact;
index.js
var http = require("http");
var routes = require("./routes.js");

http.createServer(function(request, response) {
    if (request.url === "/") {
        routes.root(request, response);
    } else if (request.url === "/contact") {
        routes.contact(request, response);
    } else if (request.url === "/about") {
        routes.about(request, response); // Handle the /about route
    } else {
        response.writeHead(404, { 'Content-Type': 'text/plain' });
        response.end("404 Not Found\n");
    }
}).listen(3000);

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Data Analysis Techdegree Graduate 49,443 Points

Hey Naquan Hayes ,

I've been trying to get through your posts and figure out how to help / reply. (note - my reply on a previous post).

I'd like to help you out but I'm not sure of specifics. If you have run into issues regarding the downloaded files, you could try opening the workspace associated with the videos and follow along how it's presented in the videos. I'm looking into the project files now but I'm not familiar with this course as I stated earlier. If there's a problem with a challenge, can you please let me know what the issue is that you're having so I can try and come to a solution?

I’m done with this