Hello, here I found a construct that i can use to pass the int value to GET request:
@http(‘GET’, ‘/get/int:value’)
def get_method(self, request, value):
return json.dumps({‘value’: value})
Is there a way to pass the file name into GET request such as or similar?
@http(‘GET’, ‘/get/str:filename’)
def get_method(self, request, filename):
return filename
If not then is there and doc or example how to do it? My task is to pass the file name and download it using nameko service.
Thank you!
Your syntax is bit off. Nameko is using werkzeug library for it’s HTTP handlers as described here: https://docs.nameko.io/en/stable/built_in_extensions.html#http
To accept a string you should decorate your get method with something like this:
@http('GET', '/files/<string:filename>')
def get_method(self, request, filename):
...
Another example: https://github.com/nameko/nameko-examples/blob/master/gateway/gateway/service.py#L25
For your first decorator:
@http('GET', '/getFileContents/<string:file_name>')
your request would be:
$ curl http://10.1.1.16:8000/getFileContents/a.txt
not sure where grab
path part came from…
Thank you for your help! Got it working.