You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
818 B
Python
34 lines
818 B
Python
7 years ago
|
import os
|
||
|
import logging
|
||
|
|
||
|
from flask import Blueprint, jsonify, request
|
||
|
|
||
|
|
||
|
LOGGER = logging.getLogger('gunicorn.error')
|
||
|
SECRET_CODE = os.environ.get('SECRET_CODE')
|
||
|
|
||
|
main_blueprint = Blueprint('main', __name__)
|
||
|
|
||
|
|
||
|
@main_blueprint.route('/ping', methods=['GET'])
|
||
|
def ping_pong():
|
||
|
LOGGER.info('Hitting the "/ping" route')
|
||
|
return jsonify({
|
||
|
'status': 'success',
|
||
|
'message': 'pong!',
|
||
|
'container_id': os.uname()[1]
|
||
|
})
|
||
|
|
||
|
|
||
|
@main_blueprint.route('/secret', methods=['POST'])
|
||
|
def secret():
|
||
|
LOGGER.info('Hitting the "/secret" route')
|
||
|
response_object = {
|
||
|
'status': 'success',
|
||
|
'message': 'nay!',
|
||
|
'container_id': os.uname()[1]
|
||
|
}
|
||
|
if request.get_json().get('secret') == SECRET_CODE:
|
||
|
response_object['message'] = 'yay!'
|
||
|
return jsonify(response_object)
|