from abc import ABCMeta, abstractmethod
class Repository(object):
__metaclass__ = ABCMeta
def __init__(self, location, repo_name=None):
self.location = location
self.repo_name = repo_name
@abstractmethoddef retrieve_file_blob(self, sha):
pass @abstractmethoddef file_exists(self, sha):
passrepository.py
| main.py | |
|---|---|
| 1 | from flask import Flask |
| 2 | from flask import Response |
| 3 | from git_repository import GitRepository |
| 4 | |
| 5 | app = Flask(__name__) |
| 6 | app.debug=True |
| 7 | |
| 8 | @app.route('/file/<sha>') |
| 9 | def retrieve_file_blob(sha): |
| 10 | repo = GitRepository('/home/j/src/git-sandbox') |
| 11 | return Response(repo.retrieve_file_blob(sha), |
| 12 | mimetype='application/octet-stream') |
| 13 | |
| 14 | @app.route('/exists/<sha>') |
| 15 | def file_exists(sha): |
| 16 | repo = GitRepository('/home/j/src/git-sandbox') |
| 17 | return Response(repo.file_exists(sha), |
| 18 | mimetype='application/octet-stream') |
| 19 | |
| 20 | if __name__ == '__main__': |
| 21 | app.run() |