Python 使用AWS Lambda重写URL路径

Python 使用AWS Lambda重写URL路径,python,aws-lambda,amazon-cloudfront,Python,Aws Lambda,Amazon Cloudfront,我想用Lamdba@Edge要重写下一个URL路径,请执行以下操作: https://example.com/app OR https://example.com/app/ TO https://example.com/app/index.html https://example.com/app/#/test123 TO https://example.com/app/index.html#/test123 使用官方文档,我编写了以下Python Lambda函数,但我不确定哪里错了 def

我想用Lamdba@Edge要重写下一个URL路径,请执行以下操作:

https://example.com/app OR https://example.com/app/ TO https://example.com/app/index.html
https://example.com/app/#/test123 TO https://example.com/app/index.html#/test123
使用官方文档,我编写了以下Python Lambda函数,但我不确定哪里错了

def lambda_handler(event, context):
    request = event['Records'][0]['cf']['request']
    if request in ('https://example.com/app', 'https://example.com/app/'):
        request = "https://example.com/app/index.html"
    else:
        request = request.replace("/#/","/index.html#/")
    return request

你犯了什么错误?你犯了什么错误?