def nginx_logs(): params = request.args if request.method == 'GET' else request.form if params.get('numbers'): top = params.get('numbers') else: top = 10 access_list = Logs.log_access(top=int(top)) code_list = Logs.log_code_list() return render_template('logstop.html', toplist=access_list, numbers=top, code_list=json.dumps(code_list))
def charts(): status_legend, status_data = Logs.log2_code_list() time_status_legend, time_status_date, time_status_data = Logs.log2_time_status( ) _map_geocoord, _map_markline, _map_markpoint = Logs.log2_map() return render_template('charts.html', status_legend=json.dumps(status_legend), status_data=json.dumps(status_data), time_legend=json.dumps(time_status_legend), time_date=json.dumps(time_status_date), time_data=json.dumps(time_status_data), map_geocoord=json.dumps(_map_geocoord), map_markline=json.dumps(_map_markline), map_markpoint=json.dumps(_map_markpoint))
def files_upload(): files = request.files.get('files') if files: filename = ''.join( random.sample(string.ascii_letters + string.digits, 8)) filepath = '/home/op/test/%s.log' % filename files.save(filepath) if Logs.logs_import_sql(filepath): flash("日志上传成功") else: flash("日志上传失败") else: flash("日志上传失败") return redirect('/logs/')
def import_logs(): if Logs.logs_import_sql(): return 'ok'