Start a server
python3 -m http.server 8000 in first-site. Open http://localhost:8000.
You will be able to
- Start
python3 -m http.server 8000inside~/projects/first-siteand openhttp://localhost:8000. - Read an access-log line and match method, path, and status to what you just did.
- Show that the same page over
file://has no status code, while overhttp://it has one.
The page is still at ~/projects/first-site/index.html. Open a terminal. Stand in that folder.
cd ~/projects/first-site
You already know 8000 is the door. Nothing is listening there yet.
Start a server. A server is a program that answers when a browser asks for a page.
python3 -m http.server 8000
python3 is the Python program. -m http.server runs the HTTP server that ships with it. 8000 is the door.
On a Mac. If a dialog asks to install command line tools, run
xcode-select --install, then try again.On Windows / WSL.
python3is already there. Type the same command.
The prompt does not come back. That is correct. The program is running, not finished.
The first line it prints is the banner. The banner is the server announcing it is up:
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
HTTP is the conversation a browser and a server use. Read the port on that line. The rest of the line can wait.
Leave this terminal open. Open a browser. Type this in the address bar, then press Enter:
http://localhost:8000
localhost is this machine, talking to itself. Your page should load. Same index.html. New address. This is the first time that file has an http:// URL.
Look at the bar. There is no /home/you/projects/first-site in it. The disk path is gone. The server is the one that still knows the folder.
Keep the old file:// tab if you still have it. Do not close the server. Do not try a phone.
The folder is the site
The server serves the current working directory. That is the folder you stood in when you started it. Not the folder named in the URL. The folder you stood in.
The URL path maps onto a file in that folder. / means the folder itself.
When the request is a folder, the server looks for an index page. The names it tries are index.html and index.htm. That is why http://localhost:8000 shows your page, not a list of names. You asked for /. The server found index.html and sent those bytes.
Type http://localhost:8000/index.html if you want the file named. The log path becomes /index.html. Same page. The slash alone was enough because of that index name.
Start the same command from home and you serve home. The banner still looks fine. The door is still 8000. The page is wrong, because index.html in first-site is not in home. Stand in ~/projects/first-site first. Then start it.
A double-click never started this conversation. That is why the local server is not optional for an http:// address. The file on disk is the same. The way it is reached is not.
The log line
Look back at the server terminal. A new line appeared when the browser loaded the page. That line is an access log. An access log is a record of one request.
Yours will have this shape:
127.0.0.1 - - [29/Jul/2026 04:26:16] "GET / HTTP/1.1" 200 -
Your clock prints a different stamp. The rest should match. 200 is the status this load got.
Click any piece of the line.
127.0.0.129/Jul/2026 04:26:16GET/HTTP/1.1200-GET is the method. A method is the kind of ask. GET means give me this.
/ is the path. A path is the file or folder that was asked for.
200 is the status. A status is the server’s short answer to that ask.
The quoted request is what the browser sent. The number after it is what the server answered. Read those three tokens against what you just did. You asked to GET /. The server answered 200.
Reload the http:// tab. Another line appears. Same shape. One request, one line. If you see no line, the load did not reach this server. Check you typed http://, not file://.
The banner went to stdout. Stdout is the stream a program prints to, unless you send it somewhere else. Each log line went to stderr. Stderr is the stream programs use for logs and errors. Both still land in this terminal.
The other tab
Switch to the old tab. The address starts file://. It still names the file on disk. Reload it.
The server terminal prints no new line. There is no status on that tab. The browser opened a file on disk. Nothing answered. No method. No path asked of a server. No 200.
file:// tab | http://localhost:8000 | |
|---|---|---|
| What opened | A file on this disk | A request to the server |
| Status | None | 200 in the log |
| Access log | No new line | One line for this load |
index.html. Only the http:// load has a status.A file:// address names a file on this computer. Sending that address to someone else does nothing useful. Their machine does not have your path. The http:// tab has a conversation. Same bytes. Only one of them has a status.
That is why a double-click is not a server. The file opened. Nobody answered.
Leave the server running. The page is live at http://localhost:8000 on this laptop. Stay on this machine. The phone comes later.
To stop the server later, click the server terminal and press Ctrl-C. You should see:
Keyboard interrupt received, exiting.
The prompt comes back. Port 8000 is a door with no program behind it again. For now, start it if you stopped it. Leave http://localhost:8000 showing the page.
Flashcards
What command starts the server in this course?
python3 -m http.server 8000, run inside ~/projects/first-site.
What does the startup banner say?
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
Which folder does the server serve?
The current working directory — wherever you stood when you started it.
Why is index.html special?
A request for a directory returns that file if it exists.
Name the four load-bearing parts of an access-log line.
Who asked, when, what they asked (method + path), and the status.
Quiz
Show answer
Answer: False
The opposite is true. file:// is the browser reading a path. There is no status code and no log line. http:// is a conversation (objective 9).
The opposite is true. file:// is the browser reading a path. There is no status code and no log line. http:// is a conversation (objective 9).
Show answer
Answer:
The client asked for / with GET. The server answered 200 — it found the page.
A full-credit answer shows: A strong answer covers: (1) method GET; (2) path /; (3) status 200 meaning success.
Method, path, status. Match those three to the click you just made (objective 8).
Sample answer
The client asked for / with GET. The server answered 200 — it found the page.
A full-credit answer shows
A strong answer covers: (1) method GET; (2) path /; (3) status 200 meaning success.
Method, path, status. Match those three to the click you just made (objective 8).
Show answer
Answer: A listing of home (or home's own index.html) — the server serves the folder it was started in
The server serves the current working directory. Start it in first-site or you are serving the wrong folder (objective 7).
The server serves the current working directory. Start it in first-site or you are serving the wrong folder (objective 7).