generated from Randers-Kommune-Digitalisering/python-app-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
27 lines (20 loc) · 800 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from flask import Flask
from healthcheck import HealthCheck
from prometheus_client import generate_latest
import logging
from utils.logging import set_logging_configuration, APP_RUNNING
from utils.config import DEBUG, PORT, POD_NAME
from job_endpoints import job_api_bp
logger = logging.getLogger(__name__)
def create_app():
app = Flask('ETL')
health = HealthCheck()
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())
app.add_url_rule('/metrics', "metrics", view_func=generate_latest)
app.register_blueprint(job_api_bp)
APP_RUNNING.labels(POD_NAME).set(1)
return app
set_logging_configuration()
app = create_app()
if __name__ == "__main__": # pragma: no cover
app.run(debug=DEBUG, host='0.0.0.0', port=PORT)