RODY/app/controller/WebStatusController.py

34 lines
777 B
Python
Raw Normal View History

2022-11-29 16:14:09 +08:00
import logging
from flask import Blueprint, app
from app.exts import redisClient
from app.utils.StandardizedOutput import output_wrapped
bp = Blueprint('WebStatus', __name__)
@bp.route('/ping', methods=['GET'])
def ping():
""" For health check.
"""
res = output_wrapped(0, 'pong', '')
return res
@bp.route('/redis/set', methods=['post'])
def redis_set():
redisClient.set('foo', 'bar', ex=60*60*6)
res = output_wrapped(0, 'set foo', '')
return res
@bp.route('/redis/get', methods=['get'])
def redis_get():
""" For health check.
"""
the_food = redisClient.get('foo')
if not the_food:
return output_wrapped(5006, 'foo', "")
return output_wrapped(0, 'foo', the_food.decode("utf-8"))