Development machine
- Levenshtein distance
- Using pylev which is pure Python.
examples/app_pylev/lambda_function.py
import json import sys sys.path.insert(0, 'pypi') import pylev def lambda_handler(event, context): if 'queryStringParameters' not in event: return { 'statusCode': 500, 'headers': { 'Content-Type': 'application/json' }, 'body': json.dumps({ 'error': 'Missing queryStringParameters' }) } if event['queryStringParameters'] == None or 'a' not in event['queryStringParameters'] or 'b' not in event['queryStringParameters']: return { 'statusCode': 400, 'headers': { 'Content-Type': 'application/json' }, 'body': json.dumps({ 'error': 'Missing field' }) } distance = pylev.levenshtein(event['queryStringParameters']['a'], event['queryStringParameters']['b']) return { 'statusCode': 200, 'headers': { 'Content-Type': 'application/json' }, 'body': json.dumps({ 'a' : event['queryStringParameters']['a'], 'b' : event['queryStringParameters']['b'], 'distance': distance, }) }
mkdir app_pylev cd app_pylev pip install pylev -t pypi zip -r ../project.zip *
- curl 'https://qspmdah6oj.execute-api.us-east-1.amazonaws.com/v0/hello?a=abd&b=acx'