Week 12 — The World Wide Web

This week's topic is about the world wide web and how it works.

Evaluation

Up to 10 points can be gained towards your final score by completing the in-class exercises on Friday.

What you will learn from this class

Preparation

This week's preparation is to watch some short videos about the World Wide Web and then to install software on your computer that will let you run your own web server.

Videos: WWW and HTTP

What is the world wide web? (4 minutes) https://www.youtube.com/watch?v=J8hzJxb0rpc
What is HTTP? (7 minutes) https://www.youtube.com/watch?v=LZJNj-HHfII
How a browser displays a web page (10 minutes) https://www.youtube.com/watch?v=DuSURHrZG6I

Software: Python 3

Linux: install from your repository manager (using, e.g., sudo apt install python3)

MacOS: install from MacPorts (using sudo port install python39) or from Homebrew (using brew install python3)

Windows: download an installer from python.org

Click here for detailed Windows instructions

When Python is installed you should be able to run either

python3 --version

or

python --version

and see something like “Python 3.5.3” or “Python 3.9.0” printed. You should also be able to run the same python3 (or python) command like this

python3 -m http.server

and see output that looks like “Serving HTTP on :: port 8000 (http://[::]:8000/) …”.

Notes

The three self-preparation videos cover the following topics.

What is the world wide web?

https://www.youtube.com/watch?v=J8hzJxb0rpc (4 minutes)

What is HTTP?

https://www.youtube.com/watch?v=LZJNj-HHfII (7 minutes)

1xx the server is providing the client with some requested information
2xx the request succeeded and the desired document or resource is provided in the response
3xx the requested resource has moved
4xx the request failed because of a client problem or error; e.g., status code 404 means “Resource Not Found”
5xx the request failed because of a server problem or error

The developers of the Firefox browser provide a nice summary of HTTP status codes here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

How a browser displays a web page

https://www.youtube.com/watch?v=DuSURHrZG6I (10 minutes)

This goes a little deeper into the topics of the other two videos and touches on how content is described in the HTML content of a web page.

More technical details

If the above videos were not detailed enough, you can find many longer videos that explain the World Wide Web in much greater detail. Here is an example that is maybe one step up in detail from the videos above: How The Web Works (12 minutes)

Exercise

If you have not already done so, follow the instructions above to install Python 3 on your computer.

With Python 3 installed, running a Web server on your computer is super easy. Create a directory to store your web site and change to it. (I usually call mine something like “html”.)

mkdir html
cd html

Use cat or nano to create a file called index.html that has the following contents:

<html>
<body>
<h1>Hello, world!</h1>
<p>Welcome to your Computer-Wide Web.</p>
</body>
</html>

In the same directory, run this command (use python if you don't have python3):

python3 -m http.server

Open a new tab in your Web browser, paste (or type) the following address into the address bar:

http://localhost:8000

and then press return. If all went well, you should see your web page.

What that URL means

Try modifying the content of the “index.html” file. For example, add more lines containing “<h1></h1>” or more lines containing “<p></p>” (with something interesting instead of “…”, obviously).

Pick a word inside a “<p></p>” section and put “<i>” in front of it and “</i>” after it.

Pick a word inside a “<p></p>” section and put “<b>” in front of it and “</b>” after it.

Try putting “<tt>” and “</tt>” around another word.

How much fun is that? 😀

Don't forget: every time you modify something in your index.html file you must reload the page in your browser to see the change. A convenient way to do this is by pressing Control+r while your browser window is active. (In conjunction with Alt+Tab to switch between applications, you can even edit the index.html file and reload the browser without ever taking your hands off the keyboard.)