api.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:science-gateway-middleware 作者: alan-turing-institute 项目源码 文件源码
def post(self):
        job_json = request.json
        if job_json is None:
            abort(400, message="Message body could not be parsed as JSON")
        # Try parsing Job JSON to Job object
        try:
            job = json_to_job(job_json)
        except:
            abort(400, message="Message body is not valid Job JSON")
        if self.jobs.exists(job.id):
            abort(409, message="Job with ID {} already "
                               "exists".format(job.id))
        else:
            # Set certain job properties when first persisted
            job.creation_datetime = arrow.utcnow()
            job.status = "Draft"
            job = self.jobs.create(job)
            return job_to_json(job), 200, {'Content-Type': 'application/json'}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号