test.py
from .test0 import *
from .test1 import *
test0.py
import json
from nameko.web.handlers import http
class InstallService:
name = "install_service"
@http('GET', '/get0/<int:value>')
def get0(self, request, value):
return json.dumps({'value': value})
@http('POST', '/post0')
def post0(self, request):
return u"received: {}".format(request.get_data(as_text=True))
test1.py
import json
from nameko.web.handlers import http
class ApiService:
name = "api_service"
@http('GET', '/get1/<int:value>')
def get1(self, request, value):
return json.dumps({'value': value})
@http('POST', '/post1')
def post1(self, request):
return u"received: {}".format(request.get_data(as_text=True))
$ nameko run test
Traceback (most recent call last):
File "/Users/MacBookPro/miniconda3/envs/python3_test/bin/nameko", line 8, in <module>
sys.exit(main())
File "/Users/MacBookPro/miniconda3/envs/python3_test/lib/python3.8/site-packages/nameko/cli/main.py", line 119, in main
args.main(args)
File "/Users/MacBookPro/miniconda3/envs/python3_test/lib/python3.8/site-packages/nameko/cli/commands.py", line 110, in main
main(args)
File "/Users/MacBookPro/miniconda3/envs/python3_test/lib/python3.8/site-packages/nameko/cli/run.py", line 181, in main
import_service(path)
File "/Users/MacBookPro/miniconda3/envs/python3_test/lib/python3.8/site-packages/nameko/cli/run.py", line 46, in import_service
__import__(module_name)
File "./test.py", line 1, in <module>
from .test0 import *
ImportError: attempted relative import with no known parent package
nameko==2.13.0
python 3.8
question
how to use nameko services in multiple files ?
thanks