def _chat_history(): history_stats(HISTORY_DIR, 7) history_file = os.path.join(HISTORY_DIR, 'last_7_days.csv') if os.path.isfile(history_file): return send_from_directory(HISTORY_DIR, os.path.basename(history_file)) else: return '', 404
def _stats(): try: data = request.args days = int(data.get('lookback', 7)) dump_history() response = history_stats(HISTORY_DIR, days) ret = True except Exception as ex: ret, response = False, {'err_msg': str(ex)} logger.error(ex) return Response(json_encode({'ret': ret, 'response': response}), mimetype="application/json")