From a URL to a response
Clients and servers
See the distinct jobs of an HTTP client and server, and why either side can be implemented with many different tools.
5 minute lesson
~~~
The client starts the exchange. It chooses a URL, builds a request, and sends it.
The server listens for requests. For each one, it decides what should happen and builds a response.
Imagine requesting /articles/hello:
- The browser sends a request for that path.
- The server matches the path to a route.
- The route loads the article.
- The server responds with HTML and a status code.
The server does not have to return a file named hello.html. A route can generate the response dynamically.
One program can play both roles. Your application server may receive a browser request, then become a client when it requests data from another API.
Think in terms of each exchange: who starts it is the client; who answers it is the server.
Lesson completed