Nameko use question

if I want to use nameko http package do I need to install rabbitmq also? for example, does running the service below requires rabbitmq installed?

import urllib
from nameko.web.handlers import http
from urllib.request import urlopen
import json

class HttpService:
name = “getFileContents”

@http('GET', '/get/<int:value>')
def get_method(self, request, value):
    return json.dumps({'value': value})

If you do not import rpc extension (from nameko.rpc import rpc) RabbitMQ will not be required.

Thank you! It is not clear from documentation if http package requires rabbitmq. And also there is so little of documentation and examples of how to start with nameko.

Are there particular things which seemed hard/confusing in the beginning?

Main documentation site is here We’re also maintaining full end-to-end examples repository here

PRs to improve documentation are always welcome!

1 Like

Thank you very much for links and for your reply. I have an issue to understand how to code the file download using nameko service. I found this example for upload file:

@http(“GET”, “/”)
def upload_file(self, request):
files = {“my_file”: open(“hello.txt”, “rb”)}
response =, files=files)
return response.text

I cant figure out how to download file. I know that it is somewhere is documentation but I cant seem to find this.

I will use curl from my client as curl http://localhost:port/command/file.txt -O and it should trigger the nameko service on front end vm and then get to the service on backend vm which will pass the file content to frontend and then to the client.

The code on frontend:

@http(‘GET’, ‘/grab/<string:cmd>/’)
def get_method(self, request, cmd):
#ip = config.get(‘IP’)
ip = ‘’
cip = “http://”+ip +":8000" +"/" + cmd
print(“IP: " + cip)
with urllib.request.urlopen(cip) as response:
html =
html = html.decode(“utf8”)
return html

The code in backend:

import os
import urllib
from nameko.web.handlers import http
from urllib.request import urlopen
import sys

class HttpService:
name = “download_file”

# Print commands
@http('GET', '/')
def get_method1(self, request):
    cmds = '''
    return cmds

@http('GET', '/getFileContents/\<string:filename\>')
def get_file(self, request, filename):
    with open('/vagrant/src/files+filename , 'r') as f:
        result ='\n', '')
    return result

However, I have an issue to pass file name as a parameter with curl. Any advice is appreciated.
Thank you.