Browse Source

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

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

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

Loading…
Cancel
Save