Files
docker-build-exercise/app.py
2023-01-13 10:51:37 +01:00

25 lines
612 B
Python
Executable File

from fastapi import FastAPI, Response
import os
# Gebruik een omgevingsvariable. Tijdens het deployen van de applicatie kan
# deze worden meegegeven, bijvoorbeeld als configMap maar ook als 'fixed'value vanuit de
# deployment manifest.
name = os.getenv("HELLO_NAME", "unknown")
hostname = os.getenv("HOSTNAME")
version = os.getenv("PYTHON_VERSION")
api = FastAPI()
@api.get("/")
async def root():
return f"This is python version {version} in container {hostname}"
@api.get("/hello")
async def hello():
return f"Hello {name}!!!"
@api.get("/healthz")
async def healthz():
return "OK"