Skip to main content

Web and HTTP Fundamentals

When you visit a website using your favorite browser (Firefox, Chrome, Edge, etc.), a connection is established through the Internet between a client, which initiates the connection and requests the content of the website, and a server, who accepts the connection and sends the requested content. Within a website we usually find different sections or pages and a multiplicity of multimedia content. Thus, the most common thing is that given a client request, the server responds with content in HTML format (embellished with CSS and JavaScript), although it can also respond with plain text, with an image, with JSON- or XML-formatted data, etc. Depending on the format in which the server transfers content, the web browser, which in this context is the client, interprets the information and shows you the proper page, or image, or document, etc.

A web server is identified by an IP address or a domain. For example, the Python Assets website is identified by the pythonassets.com domain. This domain or IP address points to a physical location where the server is hosted. The server is just an application that retrieves content when a parts of a website are requested by the browser. Companies that provide space to host server programs that respond to web requests are known as hosting providers.

When visiting a website, the communication between the client (web browser) and the server does not occur in an aribtrary fashion, but rather follows specific rules established by the HTTP protocol. This protocol determines that when a web browser wants to access a particular URL, it must establish a connection and send a request. The server then validates the request and sends a response containing the requested data.

HTTP Diagram

The request sent by the client contains some useful information to the server. For now, we are just interested in the URL and the HTTP method, which are included in the request. A URL is "the address of a given unique resource on the Web", e.g. https://pythonassets.com/categories/ is the URL of the "Categories" section in the Python Assets website. HTTP methods are a set of verbs that indicate the operation you want to execute on a given URL. In this tutorial we are only going to deal with two of them: GET and POST. The GET method is used most of the time, since it indicates that you simply want to “read” the content of a URL. On the contrary, the POST method is used when you want to send data from the web browser to the server (for example, when filling out a form or performing a search). In the following sections we will deepen these concepts.