19.2. Web Addresses

When a client makes a request to a server, it does so using a uniform resource locator (URL). URLs are also called web addresses.


As regular users of the web, we are already familiar with URLs like these:

  • https://education.launchcode.org/lchs/

  • https://en.wikipedia.org/wiki/Client–server_model

  • https://repl.it

A URL contains a lot of information about the request, including what is being requested and where it should be sent. URLs contain several parts, and the general structure looks like:


The five parts of this URL are:

  1. Scheme

  2. Host

  3. Port (optional)

  4. Path (optional)

  5. Query String (optional)

Only the scheme and host are required, and the parts must be in the exact order shown. Let’s look at each of these in detail.

19.2.1. Scheme

The first portion of every URL specifies the scheme. Common schemes include http, https, and file. The scheme usually identifies the protocol for the request. For us, this will always be http or https. If left off, a web browser will insert the scheme http/s for you.

The scheme is always followed by ://.

19.2.2. Host

The host portion of a URL specifies where the request should be sent. The host can be either an IP address, like, or a domain name, like www.launchcode.org.

19.2.3. Port

Following the host is an optional port number. The port determines which application on the server needs to handle the request.

When the port number is missing, a default value is used. For http://, the default port is 80. When using https://, the default port is 443.

Ports 80 and 443 prompt the server to run programs that handle web requests. For example, assume a server receives a request to port 443. When this happens, a special security program runs to encrypt/decrypt the data. If the request comes in at port 80, then a different program runs and handles the data without the extra security features.

19.2.4. Path

The path of a URL consists of a series of names separated by /. It looks similar to the result returned when we enter the pwd command in the terminal.

The path tells the server what is being requested. It includes a series of names that end with a specific directory or file. For example, /blog/entries/2018/ requests the contents of the 2018 directory, while /blog/index.html requests only the index.html file from the blog folder.

If the path is missing in the URL, then the root path / is used. The root path usually sends us to the home page for a given site.

19.2.5. Query String

After the path comes the query string, which begins with ?. The query itself contains a set of key-value pairs. Each pair is joined by = and is separated from the other pairs by &.

While the path specifies what the request is asking for, the query string provides additional information needed to fulfill the request. For example, a query string from a search using DuckDuckGo might look like this:


This query has two key-value pairs:

  • q : recent+nasa+images

  • ia : images

A search for “NASA” returns its home page and lots of other information. Adding the query string helps narrow down the results. In this case, we want to focus on recent images shared by NASA.

Try It!

  1. Follow the link https://google.com/?q=python and compare the query string q=python compares to the text that appears in the search box.

  2. In the address bar, change q=python to q=python+turtles and tap Enter. How does the page change?

  3. Does including the query string in the address bar actually run the Google search?

19.2.6. Video Summary

If you’d like to reinforce your reading with a video explanation for URLs, here’s a helpful, five minute clip:

19.2.7. Check Your Understanding


For the URL https://launchcode.org/lchs, identify the host.

  1. lchs
  2. https
  3. launchcode
  4. launchcode.org


For the URL https://education.launchcode.org/lchs/index.html, identify the path.

  1. /index.html
  2. /lchs/index.html
  3. /education.launchcode.org/lchs/index.html
  4. /education.launchcode.org


For the query string ?q=nasa+images&t=h_&iax=videos&ia=videos, which of the following is NOT a key/value pair?

  1. q : nasa+images
  2. t : h_iax
  3. ia : videos