def get_experiment(path):
logdir = APP.config['logdir']
complete_path = os.path.join(logdir, path)
if os.path.isfile(complete_path):
file_content = get_file(complete_path)
if path.endswith(".log"):
result = ansiconv.to_html(html.escape(file_content))
elif path.endswith(".ini"):
lexer = IniLexer()
formatter = HtmlFormatter(linenos=True)
result = highlight(file_content, lexer, formatter)
else:
result = "Unknown file type: '{}'.".format(complete_path)
else:
result = "File '{}' does not exist.".format(complete_path)
return Response(result, mimetype='text/html', status=200)
评论列表
文章目录