Pract 9
Pract 9
js and npm
✅ What is it?
How to check:
node -v
npm -v
If both versions show, you're good. If not, download and install from:
👉 https://nodejs.org/
---
mkdir express-pract9
cd express-pract9
✅ Why?
---
npm init -y
✅ Why?
This creates a package.json file, which keeps track of your project settings and dependencies.
✅ What is it?
---
mkdir public
touch public/index.html
touch server.js
mkdir public
echo > public\index.html
echo > server.js
✅ Why?
---
<!DOCTYPE html>
<html>
<head>
<title>Static Page</title>
</head>
<body>
<h1>Welcome to the Static Page</h1>
</body>
</html>
---
// Start server
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});
---
node server.js
Static: 👉 http://localhost:3000/
Dynamic: 👉 http://localhost:3000/hello