Your packing list is finished, and you can explain every part of it. Right now, though, it only runs on your computer, through your local server. Alex wants it on their phone at the airport, and that means putting the folder online. Publishing is up to you, since it needs a GitHub account and a public repository. This lesson needs neither, because every check in it runs against the folder you already have.
In this lesson, you’ll predict what changes once the packing list is served from a public address instead of your local server. You’ll spot which paths and filenames break, work out whose saved trips each visitor sees, and check what anyone can read in your code. The first prediction is about where each of the page’s files comes from.
Follow Each Path to the Server
A static host is a server on the internet that hands out your folder’s files exactly as they are, the same job your local server does on your computer. GitHub Pages is a free static host. Your files go into a repository, GitHub’s name for a project folder stored on its site, and your site’s address is https://<username>.github.io/<repository>/. When an address ends in a folder like that, the server sends that folder’s index.html.
Say Ada has a recipe box she built and tested on her Mac. She opened the recipes folder itself in her editor, so Live Preview served it at http://127.0.0.1:3000/index.html, and everything worked. Her page loads a stylesheet and a module:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Ada's Recipes</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<h1>Ada's Recipes</h1>
<ul id="recipes"></ul>
<script type="module" src="./Main.js"></script>
</body>
</html>
Her other two files are short, and each one leaves a mark you can see. The stylesheet colors the heading:
style.css
h1 {
color: darkgreen;
}
The module fills the empty list with her recipes, using textContent so each name goes in as plain text:
main.js
const recipes = [
"Lemon pancakes",
"Tomato soup",
"Veggie chili",
];
const list = document.querySelector("#recipes");
for (const name of recipes) {
const item = document.createElement("li");
item.textContent = name;
list.append(item);
}