[08.10.20] New probe configuration

This commit is contained in:
andrewso 2020-10-08 13:49:45 +01:00
parent 6c1f107ed0
commit 0253bab66e

View File

@ -2,14 +2,9 @@
from flask import Flask
import json
import requests, json
import logging as logger
logger.basicConfig(
level=logger.INFO,
format="%(asctime)s: %(levelname)s -- %(message)s",
datefmt='%Y-%m-%d %H:%M:%S'
)
import json
app = Flask(__name__)
@ -19,27 +14,27 @@ def health():
@app.route('/readiness')
def readiness():
# Can it make a call to an exchange?
price = 23
result = requests.request("GET", 'http://0.0.0.0:9090/predict?tweet=Test%20Tweet%20for%20bitcoin%20predictions')
result = json.loads(result.text)
if price != 0 :
if result != "":
return json.dumps({
'status': 'UP',
'app': {
'name': 'CryptoSky Price Collector',
'description': 'Projects Price Collector service that collects the: High, Low, Open, Close prices, Volume and calculates average price for the hour.',
'check_status': 'Success - Call to coinbase exchange',
'price': price
'name': 'CryptoSky spam filter',
'description': 'Projects spam filter service that classifies whether the tweet that is sent to it is spam or not',
'check_status': 'Success - Call to prediction endpoint',
'response': result
}
}), 200, {'ContentType': 'application/json'}
else:
return json.dumps({
'status': 'DOWN',
'app': {
'name': 'CryptoSky Price Collector',
'description': 'Projects Price Collector service that collects the: High, Low, Open, Close prices, Volume and calculates average price for the hour.',
'check_status': 'Failed - Call to coinbase exchange',
'price': price
'name': 'CryptoSky spam filter',
'description': 'Projects spam filter service that classifies whether the tweet that is sent to it is spam or not',
'check_status': 'Failure - Call to prediction endpoint',
'response': result
}
}), 503, {'ContentType': 'application/json'}