我在名为requestHandler.py 的python 中创建了一个基于类的 AWS lambda 函数,如下所示
from action_dispatcher import ActionDispatcher
class RequestHandler(ActionDispatcher):
@staticmethod
def createTemplate(event, context):
return "Hello world"
我的action_dispatcher.py如下所示。
import json
class ActionDispatcher(object):
def __call__(self, event, context, *args, **kwargs):
action = event.get('action')
handler = getattr(self, action, None)
if handler is None:
return json.loads({'status': 'error', 'code': 404, 'message':"Action {0} not found.".format(action) })
return handler(request, *args, **kwargs)
使用上述设置和 lambda 处理程序作为requestHandler.RequestHandler,我收到错误“RequestHandler() 不接受任何参数”,在这种情况下,我将操作创建为 createTemplate。所以我想从 RequestHandler 调用这个方法。
翻过高山走不出你
翻翻过去那场雪
烙印99
相关分类