123456789101112131415161718192021222324252627282930313233 |
- from flask import abort, jsonify
- from flask.views import View
- from pycs.database.Database import Database
- class ListFiles(View):
- """
- return a list of files for a given project
- """
- # pylint: disable=arguments-differ
- methods = ['GET']
- def __init__(self, db: Database):
- # pylint: disable=invalid-name
- self.db = db
- def dispatch_request(self, project_id: int, start: int, length: int):
- # find project
- project = self.db.project(project_id)
- if project is None:
- return abort(404)
- # get file list
- count = project.count_files()
- files = project.files(start, length)
- # return files
- return jsonify({
- 'count': count,
- 'files': files
- })
|