Skip to content
Shop

CommunityJoin Our PatreonDonate

Sponsored Ads

Sponsored Ads

Server ​

You will learn how data is shared between two different applications.

Brian Long
Senior Developer

I had to keep that glitch in there because it's too funny. 🤪

Server and Client ​

Think of a server as a really powerful computer that's always on and ready to help. It's like a shop that’s open 24/7, waiting for customers to come in. The customers, in this case, are the clients. When you open a web browser or an app, you're essentially acting as the client, making a request to the server to fetch some information for you, like a webpage or a video.

How They Work ​

Here's how the whole thing works: The client (your browser) sends a request to the server. The server then processes that request, grabs the information you want (like a web page), and sends it back to your browser to display. This all happens in a split second, so fast that it feels instant.

For example, when you type in "www.example.com," your browser sends a request to the server that hosts the website for "example.com." The server processes your request and sends the webpage back to your browser to display. Pretty neat, right?

URLs and Resources ​

Now, what’s a URL? It’s like the address you type into your GPS. When you type https://www.example.com into your browser, you’re telling the client where to go and what to get. The URL (Uniform Resource Locator) is the address of the resource you want, like a web page, an image, or even a downloadable file.

In this analogy, the resources are like the different products in the shop (server). It could be anything—webpages, images, files—whatever you're asking for when you hit enter.

Port Numbers and Endpoints ​

Imagine the server has many different doors (port numbers) and rooms (endpoints). When the client makes a request, it needs to know which door to knock on. The port number tells the server exactly which service the client wants to interact with. The default door for web traffic is port 80 (for HTTP) or port 443 (for HTTPS).

Endpoints, on the other hand, are like specific rooms in the shop. They tell the server exactly where to go inside to find what you need. For example, if you want to see a user profile on a website, the URL might look something like https://www.example.com/user/123. Here, user/123 is the endpoint directing the server to the correct resource—the user profile with ID 123.

In a Nutshell ​

So, the next time you're browsing the web, just remember that your browser is the client, asking a server for directions to the information you want, and using URLs, port numbers, and endpoints to get there. It’s like a well-organized system of requests and responses that makes the internet work smoothly!

Example ​

The words "server" and "client" have dual meanings. A server can also refer to the actual software on a computer that serves information (like the code below) while a client can refer to the software that receives the information (Google Chrome).

python
from flask import Flask

app = Flask(__name__)
port = 3000

@app.route('/')
def index():
    return "Serving some delicious text"

@app.route('/math')
def math():
    return str(3 + 9)

if __name__ == '__main__':
    print("Server is listening on port " + str(port))
    app.run(debug=True,port=port)

The two endpoints for the server above are:

/
/math
markdown
/myapp
    server.py
    templates/
        index.html
python
from flask import Flask,render_template

app = Flask(__name__)
port = 3000

@app.route('/')
def index():
    data = {"color": "red","shape": "round", "weight": .33}
    return render_template('index.html', data=data)

if __name__ == '__main__':
    print("Server is listening on port " + str(port))
    app.run(debug=True,port=port)
html
<div>
    <h1>Data from the server</h1>
    {{data}}
</div>

Resources ​