liveBook · Manning

Server

As explained in The Well-Grounded Python Developer: How the pros use Python and Flask

Server software is software that provides network-accessible functionality and enables a computer to act as a server.

A server is software running on a computer that provides functionality to other applications across a network. It is the software—not special hardware—that makes the computer a server. Running a web application on your own computer is enough to put it in that role. section 6.2

In the client-server model, several clients can use one central server. A web server responds to HTTP requests from clients such as browsers. The browser interprets a returned HTML document as a page; links in that page can trigger further requests for CSS, JavaScript, and other content. section 6.2 section 6.3

In the request-response model, the server processes a client's request and sends back a response rather than acting on its own. It may retrieve database data to compose a page, then serve linked files as the browser requests them. Keeping the application on a central server also lets an update become available to users without distributing new software to each computer. section 6.2.1 section 6.1.1

from flask import Flask      #1
 
app = Flask(__name__)        #2
 
@app.route("/")              #3
def home():                  #4
    return "Hello World!"

This small Flask application creates a server-backed route at `/` whose response is `Hello World!`. It is a starting point for seeing a browser request reach application code. section 6.4.2

Run the Flask example with `flask run`, then visit `http://127.0.0.1:5000` in a browser. The process waits for requests until stopped. Flask's built-in development server is useful locally, but is not secure or optimized enough for a publicly available production application. section 6.4.2

How The Well-Grounded Python Developer: How the pros use Python and Flask covers it

How deep it goes
Defines server software, traces browser request-response behavior, and runs a local Flask example; leaves HTTP protocol details beyond scope.
Examples
Uses a Flask Hello World route and a browser request to localhost to show a server receiving and answering requests.
What it assumes
Assumes familiarity with Python development tools and applications while defining what a server does and introducing the browser-server exchange.
What you can do after
Operate/configure it: run the Flask development server locally and recognize why it should not serve a public production application.
How it connects
Connects the client-server model and HTTP request-response behavior to browsers, HTML, CSS, JavaScript, and databases.

Also explained in

Compare how 11 books explain server →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Python Developer: How the pros use Python and Flask. The section links point to the parts of the book it draws on.