Skip to main content

Exercise 16

  • Create the following folder/file structure:
/ex_16
├── index.js
└── index.html
└── public
├── css
└── style.css
├── js
└── script.js
├── img
└── foto.png

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Static documents using Node & Express</title>
<link rel="stylesheet" href="/css/styles.css" />
<script src="/js/script.js"></script>
</head>
<body>
<h1>Rick & Morty!!</h1>
<img src="/img/yeay.jpg" alt="Let's go" />
</body>
</html>

css/style.css

body {
background-color: #eee;
color: green;
font-family: Arial, Helvetica, sans-serif;
}

h1 {
font-weight: normal;
}

img {
border-radius: 5px;
}

js/script.js

console.log("Static files from the server!!!");

img

index.js

  • Create a Express web server using port 3000
  • Configure express static folder to use the public folder
  • Create an assets alias