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 trialMarc-Oliver Gern
8,747 Points'Create a web server' code snippet changed on nodejs.org
I've noticed that the code snippet used in the video for creating a web server changed on nodejs.org and they now introduced arrow functions. See the code that worked for me below. There is a good video on Youtube if you want to know more about Arrow Functions, which were introduced in ECMA 6: https://www.youtube.com/watch?v=6sQDTgOqh-I
//1. Create a web server
const http = require('http');
const port = 3000;
const server = http.createServer((request, response) => {
if(request.url === "/") {
response.statusCode = 200;
response.setHeader('Content-Type', 'text/plain');
response.write("Header\n");
response.write("Search\n");
response.end("Footer\n");
}
});
server.listen(port, () => {
console.log(`Server running at http://${port}/`);
});