openflexure-microscope-server/openflexure_microscope/common/flask_labthings/views/tasks.py
2020-01-06 22:28:00 +00:00

40 lines
877 B
Python

from flask import abort, url_for
from ..decorators import marshal_with
from ..resource import Resource
from ..schema import TaskSchema
from openflexure_microscope.common.labthings_core import tasks
class TaskList(Resource):
"""
List and basic documentation for all session tasks
"""
@marshal_with(TaskSchema(many=True))
def get(self):
return tasks.tasks()
class TaskResource(Resource):
@marshal_with(TaskSchema())
def get(self, id):
try:
print(tasks.dict())
task = tasks.dict()[id]
except KeyError:
return abort(404) # 404 Not Found
return task
@marshal_with(TaskSchema())
def delete(self, id):
try:
task = tasks.dict()[id]
except KeyError:
return abort(404) # 404 Not Found
task.terminate()
return task