import json from search import search from suggest import suggest def handler(action, query): action = action.lower() res = {"msg": "Failed to handle request"} if action == "search": res = search(query) elif action == "autosuggest": res = suggest(query) return json.dumps(res)