GetProjectResults.py 672 B

12345678910111213141516171819202122232425
  1. from flask import jsonify
  2. from flask.views import View
  3. from pycs.database.Project import Project
  4. from pycs.interfaces.MediaStorage import MediaStorage
  5. class GetProjectResults(View):
  6. """
  7. get a list of all files and annotations for a project
  8. """
  9. # pylint: disable=arguments-differ
  10. methods = ['GET']
  11. def dispatch_request(self, project_id: int):
  12. # get project from database
  13. project = Project.get_or_404(project_id)
  14. # map media files to a dict
  15. storage = MediaStorage(project.id, None)
  16. files = list(map(lambda f: f.serialize(), storage.files().iter()))
  17. # return result
  18. return jsonify(files)