Python is a programming language used here to build a small web application. Alongside a JavaScript/Node.js application, it provides a concrete way to compare deployment methods: the application stays recognizable while its packaging and runtime change. section 2.0 section 1.2
A deployable Python application needs more than its source code:
- FastAPI handles web requests and responses; functions can map URLs and HTTP methods to behavior. section 2.5
- A requirements.txt file records third-party packages so the application’s environment can be recreated. section 2.5
- A virtual environment gives the server a designated place to install and run those packages. section 3.4.1
Set up Python on an Ubuntu server
Check the installed version with python3 --version. Install python3, python3-venv, python3-pip, and build-essential with apt; Ubuntu may need these additional packages even when Python 3 is already present. Create an environment with python3 -m venv /opt/venv/, then use its Python executable to install the application’s requirements. The example server runs the app with Gunicorn and a Uvicorn worker on port 8888. section 3.4.1
Listing 3.18 Installing Python packages with absolute paths
/opt/venv/bin/python -m pip install -r \
/opt/venv/roadtok8s/py/src/requirements.txt
The command installs packages from requirements.txt using the virtual environment’s Python executable, making both the installer and dependency list explicit. section 3.4.1
A container offers another way to select the Python runtime. Rather than relying on the server’s default version, choose a version-tagged Python image from Docker Hub. For example, docker run -it python:3.11.4 starts an interactive Python shell in that image; the same tag can identify the base image in a Dockerfile. section 5.3.1

























