Your First Node.js Web Server

Web Dev Simplified · 628K views · 2018 · 8:57

Open on YouTube

Web developmentPython, Ruby & scripting languagestutorial

Why Stack Overflow recommends it

Stack Overflow users link it as a starter guide for setting up a Node.js server, and askers cite it as the tutorial they followed when their code did not behave as shown.

Recommended by 1 people across 1 different months, 2021 to 2023.

What it is

A short beginner tutorial from Web Dev Simplified that walks through installing Node.js and building a first basic web server with the built-in http module. It ends with a working server that serves HTML files from disk.

What people said

Recommends Airumoo · 2023-09 · Stack Overflow · on “Create a server with Python”

Here are some guides on making a node.js along with a python webserver [this video] - node.js [LINK] <- py This should answer everything you need

Cites RealDevMashup · 2021-06 · Stack Overflow · on “How to create a header for a website that i can change in one file using node.js”

I'm trying to create a node.js header for a website I'm working on from a video, but no matter how much the video [this video] claimed to be simple, I cannot fiqure out what I'm doing wrong const http = require('http'); const fs = require("fs"); const port = 3000; const server = http.createServer(function(req, res) { res.writeHead(200, { 'Content-Type': 'text/html' }) fs.readFile('Header.html', function(error, data) { if(error) { res.writeHead(404) res.write('Error: Header not found') } else { res.write(data) } res.end() }) }) server.listen(port, function(error) { if(error) { console.log("Something went wrong: " + error); } else { console.log("Server is up and running on port " + port); } })

Cites rochard · 2023-03 · Stack Overflow · on “How to fix HTTP module not working in Node.js?”

I was following this tutorial [this video] and my code looks exactly the samein the part at 5:00 yet it doesnt work. Here's my code const http = require('http') const port = 3000 const server = http.createServer(function(req, res){ res.write('Hello Node') res.end }) server.listen(port, function(error){ if(error){ console.log("Error: " + error) } else { console.log("Server is listening on port " + port) } }) I tried using a different browser but nothing changed.