diff options
Diffstat (limited to 'apitest.py')
-rw-r--r-- | apitest.py | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -32,6 +32,10 @@ import apifw class Api(apifw.Api): + def __init__(self): + super().__init__() + self._blob = None + def find_missing_route(self, path): logging.info('find_missing_route called!\n') return [ @@ -45,6 +49,11 @@ class Api(apifw.Api): 'path': '/upload', 'callback': self.upload, }, + { + 'method': 'GET', + 'path': '/download', + 'callback': self.download, + }, ] def version(self, content_type, body, **kwargs): @@ -57,6 +66,7 @@ class Api(apifw.Api): }) def upload(self, content_type, body, **kwargs): + self._blob = body return apifw.Response({ 'status': apifw.HTTP_OK, 'body': 'thank you for %s\n' % body.decode('ascii'), @@ -65,6 +75,15 @@ class Api(apifw.Api): }, }) + def download(self, content_type, body, **kwargs): + return apifw.Response({ + 'status': apifw.HTTP_OK, + 'body': self._blob, + 'headers': { + 'Content-Type': 'text/plain', + }, + }) + # We want logging. gunicorn provides logging, but only of its own # stuff, and if we log something ourselves, using logging.debug and |