# How to pass file name as a parameter to nameko @http GET?

**URL:** <https://discourse.nameko.io/t/how-to-pass-file-name-as-a-parameter-to-nameko-http-get/447>\
**Category:** Uncategorized\
**Created:** [June 3, 2019, 8:53pm UTC](https://discourse.nameko.io/t/how-to-pass-file-name-as-a-parameter-to-nameko-http-get/447 "2019-06-03T20:53:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xolosno](https://avatars.discourse-cdn.com/v4/letter/x/7feea3/32.png) [@xolosno](https://discourse.nameko.io/u/xolosno)\
**Post date:** [June 3, 2019, 8:53pm UTC](https://discourse.nameko.io/t/how-to-pass-file-name-as-a-parameter-to-nameko-http-get/447/1 "2019-06-03T20:53:09Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Jakub\_Borys](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/jakub_borys/32/7_2.png) [@Jakub\_Borys](https://discourse.nameko.io/u/Jakub_Borys)\
**Post date:** [June 3, 2019, 10:00pm UTC](https://discourse.nameko.io/t/how-to-pass-file-name-as-a-parameter-to-nameko-http-get/447/2 "2019-06-03T22:00:02Z")

</div>

Your syntax is bit off. Nameko is using [werkzeug](https://palletsprojects.com/p/werkzeug/) library for it’s HTTP handlers as described here: [https://docs.nameko.io/en/stable/built\_in\_extensions.html#http](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:

```python
@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](https://github.com/nameko/nameko-examples/blob/master/gateway/gateway/service.py#L25)

---

<div class="post-metadata">

**Author:** ![Jakub\_Borys](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/jakub_borys/32/7_2.png) [@Jakub\_Borys](https://discourse.nameko.io/u/Jakub_Borys)\
**Post date:** [June 4, 2019, 6:11am UTC](https://discourse.nameko.io/t/how-to-pass-file-name-as-a-parameter-to-nameko-http-get/447/4 "2019-06-04T06:11:18Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![xolosno](https://avatars.discourse-cdn.com/v4/letter/x/7feea3/32.png) [@xolosno](https://discourse.nameko.io/u/xolosno)\
**Post date:** [June 4, 2019, 3:43pm UTC](https://discourse.nameko.io/t/how-to-pass-file-name-as-a-parameter-to-nameko-http-get/447/5 "2019-06-04T15:43:16Z")

</div>

Thank you for your help! Got it working.
