Starting server

Hello,
I was just trying to figure out what is the difference between starting a server and just opening an HTML file?
If anyone can explain in plain language or give me a link to a comprehensive article it would be great.
Thanks in advance.

An HTML file is something that, when viewed through a browser, can display a web page. The question is, how do you get that HTML file? Did you write it yourself and save it to your desktop, or did you get it from a website? If you went to a website, what really happened (in some form or another) is that you connected to a server and asked it for an HTML file. The server than has code on it that prepares the HTML file and sends it to you, so you can view it in your browser. The server is also the place that stores all the data that your HTML files need (or knows where that data is stored).

An HTML file is the product you want, and a server is the creator/distributor of that product.

Yeap, I understand. I should probably explain a bit more.
For example, I developed something locally and want to put it on a server. How would I know what the server is going to do with my app or site?
In other words, if it works locally but does not work on the server, how do I figure out why?

Simply put, Server is literally a normal computer running special software to do something. In this case, to give you the web page you requested.

Here’s how a basic html webpage hosted on a server would work.

  1. When you enter some URL, the URL is translated to an IP address of it’s server by DNS (how? not important for now)
  2. Your browser then sends a request to the server computer using it’s IP address.
  3. Server computer routes your request to the special software running inside it and the special software returns the html file you requested for some URL.
  4. Server computer then replies to your request with the html file to the browser and the browser displays it to you.

Here’s something more: For basic html websites, the front page is index.html. When you open a URL, the contents of the file you’re seeing is actually stored as index.html on the server.

1 Like

Thanks, man. Very clear!

A server is a program that provides some functionality to other programs. They connect to the server and do {stuff}: you have a program that sends some commands to the server, and the server does some stuff and normally sends a response.

In your context, a server is, practically, a program running on a computer somewhere that you can connect to over a network. So you have an application, and you put the files on that computer, and start the server, and you can go to the URI that points at that computer (and the port that program runs on). And then you can send things to the server and it’ll respond: in a web context these use a protocol called HTTP.

So to be even more specific, what I think you’re talking about is what’s called a “local” server serving an HTML file (you make a request using HTTP to a server Vs just opening the HTML file). So if you just open an HTML file, things like the scripts are going to be imported from your local computer by your browser (instead of a URL of a computer somewhere it looks for a file on your computer). If you run a server program, your browser is going to connect to it and download files and run them from there (the fact the server is running on your computer is irrelevant), it’s how it would work IRL

1 Like