You can find the library to expose metrics from Python at https://github.com/prometheus/client_python and can install it using pip with this command:
pip install prometheus_client
For our flask example, you can download the full sample code from https://github.com/kubernetes-for-developers/kfd-flask from branch 0.5.0. The commands to get this updated sample are:
git clone https://github.com/kubernetes-for-developers/kfd-flask -b 0.5.0
If you look within exampleapp.py, you can see the code where we use two metrics, a histogram and a counter, and use the flask framework to add in callbacks at the beginning ...