Browse Source

by default, /api/build doesn't wait for build to complete

master
Youen 2 years ago
parent
commit
8e564c1ef4
  1. 6
      src/api/api_document.py

6
src/api/api_document.py

@ -2,6 +2,7 @@ from flask import Blueprint, request
from web_utils.get_arg import get_arg
from web_utils.business_exception import BusinessException
import os
import time
from data.document import Document
@ -13,13 +14,18 @@ def build():
doc_name = get_arg('doc_name')
branch = get_arg('branch', 'master')
apikey = get_arg('apikey')
join = get_arg('join', 'false')
doc = Document(origin, doc_name, branch)
if doc.get_api_key() != apikey:
raise BusinessException("Invalid API key")
build_task = doc.build()
if join == 'true':
build_task.join()
else:
time.sleep(1)
return build_task.get_output_str().replace('\n', '<br/>\n')

Loading…
Cancel
Save