Web Lambda Handler#

Web lambda handler

This code provides the lambda handler for requests from websites.

lambdaHandlers.web_handler.build_web_response(text_output)#

Build the web response

lambdaHandlers.web_handler.on_web_intent(intent)#

Get a random module at the specified CR and/or environment for the web interface

>>> import random
>>> random.seed(13)
>>> # valid monster intent
>>> monster_intent = {
...             'web': True,
...             'ip': "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
...             'name': "MonsterByCRandEnvironment",
...             'slots': {
...                     'cr': {'value': "2"},
...                     'env': {'value': "swamp"}
...             }
...     }
>>> on_web_intent(monster_intent)
{'body': '--- Random Monster ---\nswarm of poisonous snakes - HP: 86-100'}
lambdaHandlers.web_handler.web_lambda_handler(event, context)#

Route the incoming request based on type. The JSON body of the request is provided in the event parameter.

>>> import random
>>> random.seed(13)
>>> # valid monster intent
>>> monster_intent = {
...             'web': True,
...             'ip': "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
...             'name': "MonsterByCRandEnvironment",
...             'slots': {
...                     'cr': {'value': "2"},
...                     'env': {'value': "swamp"}
...             }
...     }
>>> web_lambda_handler(monster_intent, "")
{'body': '--- Random Monster ---\nswarm of poisonous snakes - HP: 86-100'}