问题描述
我正在一个项目中,我用Bottle创建的API需要集成到一个类中。我不确定如何将其功能集成到类方法中。这不起作用:
class Rest_API:
def __init__(self):
pass
def generic_function(self,input):
return("Generic Function Result: {}".format(input))
my_api = Rest_API()
#DOESN'T WORK
bottle.get("/generic_url")(my_api.generic_function(input))
run(host='localhost',port=8080,debug=True)
错误如下:
ModuleNotFoundError: No module named 'Generic Function Result'
下面的版本可以运行,但是不能满足我的需要,因为该功能需要输入。
class Rest_API:
def __init__(self):
pass
def generic_function(self):
return("Generic Function Result")
my_api = Rest_API()
bottle.get("/generic_url")(my_api.generic_function)
run(host='localhost',debug=True)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)