Serving static files through HTTP is not a difficult task. Every little web developer is doing it. But not many people understand the real action that is happening underneath. HTTP protocol is very simple to understand and needs to be understood by everyone as it is one of the most used protocols in the world wide web.
Working of HTTP
The working of the protocol is very simple. It works on the basis of the request and response. A client (generally a user’s browser) makes a request for a particular file and the server it. There are 4 basic types of requests: GET, POST, PUT and DELETE. GET is the most used type of request. When a URL is entered into the browser, the browser makes a GET request to the server. The server serves the required HTML file and the browser renders it.
But for this, we need to have a server which is capable of accepting requests and processing them. There are several tools available to make a simple HTTP server. We are going to have a look at some of them today.
Tools for creating an HTTP server
But the thing about Apache is, it requires you to place all the files you want to serve into a folder called WWW inside the directory where Apache is installed. This is not very convenient if you want to create a server on your own personal machine.
python -m SimpleHTTPServer