This project mirrors the Node.js translation service from workshop-nodejs-hello_nodejs, delivering the same behaviour using Python and FastAPI. It exposes a single endpoint that returns a localized greeting with an ISO-8601 timestamp appended.
- Python 3.10 or newer
- pip
Create a virtual environment and install the development dependencies:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txtpython -m pytestuvicorn app.main:app --host 0.0.0.0 --port 8080The server listens on port 8080 by default. Override with the PORT environment variable if needed.
GET /– Responds with a greeting string such ashello world @ 2024-06-01T12:34:56.000Z.
Environment variables provide the same configurability as the Node.js version:
TRANSLATION_DEFAULT_LANGUAGE(default:EN) – Two-letter code used to choose the greeting.TRANSLATION_FILE(default:translations.json) – File located in theresources/directory that contains the greeting map.PORT(default:8080) – Port for the HTTP server.
All translations are stored in resources/translations.json, copied verbatim from the Node.js project.