forked from manasesjesus/c8y_microservice-python
-
Notifications
You must be signed in to change notification settings - Fork 2
/
application.py
34 lines (29 loc) · 916 Bytes
/
application.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
28
29
30
31
32
33
34
#!flask/bin/python
from flask import Flask, jsonify
import os
app = Flask(__name__)
# Hello world endpoint
@app.route('/')
def hello():
return 'Hello world!'
# Verify the status of the microservice
@app.route('/health')
def health():
return '{ "status" : "UP" }'
# Get environment details
@app.route('/environment')
def environment():
environment_data = {
'platformUrl': os.getenv('C8Y_BASEURL'),
'mqttPlatformUrl': os.getenv('C8Y_BASEURL_MQTT'),
'tenant': os.getenv('C8Y_BOOTSTRAP_TENANT'),
'user': os.getenv('C8Y_BOOTSTRAP_USER'),
'password': os.getenv('C8Y_BOOTSTRAP_PASSWORD'),
'microserviceIsolation': os.getenv('C8Y_MICROSERVICE_ISOLATION')
}
return jsonify(environment_data)
if __name__ == '__main__':
import logging
logging.basicConfig(level=logging.INFO)
from waitress import serve
serve(app, host="0.0.0.0", port=80)