mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 16:58:12 +00:00
Add rest call to get job logs
This commit is contained in:
@@ -9,7 +9,7 @@ from datetime import datetime
|
||||
from zipfile import ZipFile
|
||||
|
||||
import requests
|
||||
from flask import Flask, request, render_template, send_file, after_this_request
|
||||
from flask import Flask, request, render_template, send_file, after_this_request, Response
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from lib.render_job import RenderJob
|
||||
@@ -44,6 +44,20 @@ def get_job_status(job_id):
|
||||
return f'Cannot find job with ID {job_id}', 400
|
||||
|
||||
|
||||
@server.get('/api/job/<job_id>/logs')
|
||||
def get_job_logs(job_id):
|
||||
found_job = RenderQueue.job_with_id(job_id)
|
||||
if found_job:
|
||||
log_path = found_job.worker.log_path
|
||||
log_data = None
|
||||
if log_path and os.path.exists(log_path):
|
||||
with open(log_path) as file:
|
||||
log_data = file.read()
|
||||
return Response(log_data, mimetype='text/plain')
|
||||
else:
|
||||
return f'Cannot find job with ID {job_id}', 400
|
||||
|
||||
|
||||
@server.get('/api/file_list/<job_id>')
|
||||
def get_file_list(job_id):
|
||||
found_job = RenderQueue.job_with_id(job_id)
|
||||
|
||||
Reference in New Issue
Block a user