6
0

GetResults.py 632 B

12345678910111213141516171819202122232425262728
  1. from flask import abort, jsonify
  2. from flask.views import View
  3. from pycs.database.Database import Database
  4. class GetResults(View):
  5. """
  6. returns a list of a files results
  7. """
  8. # pylint: disable=arguments-differ
  9. methods = ['GET']
  10. def __init__(self, db: Database):
  11. # pylint: disable=invalid-name
  12. self.db = db
  13. def dispatch_request(self, file_id: int):
  14. # get file from database
  15. file = self.db.file(file_id)
  16. if file is None:
  17. return abort(404)
  18. # get results
  19. results = file.results()
  20. # return result
  21. return jsonify(results)