from flask import jsonify from flask.views import View from pycs.database.Project import Project from pycs.interfaces.MediaStorage import MediaStorage class GetProjectResults(View): """ get a list of all files and annotations for a project """ # pylint: disable=arguments-differ methods = ['GET'] def dispatch_request(self, user: str, project_id: int): # pylint: disable=unused-argument # get project from database project = Project.get_or_404(project_id) # map media files to a dict storage = MediaStorage(project.id, None) files = list(map(lambda f: f.serialize(), storage.files().iter())) # return result return jsonify(files)