You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
691 B

import os
import json
from flask import request
log_file_path = '/data/ww/py_sys_monitor/info/access_log'
def get_request_info(page_index=1, page_size=10):
if page_index <= 0:
page_index = 1
if page_size <=0 | page_size > 20:
page_size = 10
request_info = []
with open(log_file_path, 'r') as f:
lines = f.readlines()
total_records = len(lines)
start = (page_index - 1) * page_size
end = start + page_size
if start < total_records:
for line in lines[start:end]:
record = json.loads(line.strip())
request_info.append(record)
return {"request_info": request_info, "total": total_records}