admin管理员组文章数量:1126301
I have an AWS lambda built using Flask, served through API Gateway. This is deployed to AWS using Terraform. I am unable to get the favicon to load correctly when deployed through this method. The favicon works flawlessly on my local machine.
Following the advice discovered here, I am able to get the icon URL to no longer return a 502; it returns a 200. However, the icon is unable to be displayed. I can navigate directly to the icon in the browser, but I still have the same undisplayed image.
I have tried using a PNG instead of ICO, with the same results.
Of note, when I am able to see the icon locally, I see it loads with type image/x-icon, but remotely it loads as image/vnd.microsoft.icon.
My handler setup:
def handler(event, context):
base64_content_types = ["image/vnd.microsoft.icon", "image/x-icon"]
return awsgi.response(app, event, context, base64_content_types)
HTML link
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
favicon.ico is stored in the /static directory.
API specs in Terraform
resource "aws_api_gateway_rest_api" "api" {
body = jsonencode({
"openapi" : "3.0.1",
"info" : {
"title" : var.project,
"description" : "Created by Terraform",
"version" : "2024-11-06T18:14:04Z"
},
"servers" : [ {
"url" : var.url
} ],
"paths" : {
"/{proxy+}" : {
"options" : {
"parameters" : [ {
"name" : "proxy",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "200 response",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Empty"
}
}
}
}
},
"x-amazon-apigateway-integration" : {
"type" : "mock",
"responses" : {
"default" : {
"statusCode" : "200"
}
},
"requestTemplates" : {
"application/json" : "{\"statusCode\": 200}"
},
"passthroughBehavior" : "when_no_match",
"cacheNamespace" : "q0jmk9",
"cacheKeyParameters" : [ "method.request.path.proxy" ]
}
},
"x-amazon-apigateway-any-method" : {
"parameters" : [ {
"name" : "proxy",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"x-amazon-apigateway-integration" : {
"type" : "aws_proxy",
"httpMethod" : "POST",
"uri" : aws_lambda_function.dss_lambda.invoke_arn,
"requestParameters" : {
"integration.request.path.proxy" : "method.request.path.proxy"
},
"passthroughBehavior" : "when_no_match",
"timeoutInMillis" : 29000
}
}
},
"/" : {
"options" : {
"responses" : {
"200" : {
"description" : "200 response",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Empty"
}
}
}
}
},
"x-amazon-apigateway-integration" : {
"type" : "mock",
"responses" : {
"default" : {
"statusCode" : "200"
}
},
"requestTemplates" : {
"application/json" : "{\"statusCode\": 200}"
},
"passthroughBehavior" : "when_no_templates"
}
},
"x-amazon-apigateway-any-method" : {
"x-amazon-apigateway-integration" : {
"type" : "aws_proxy",
"httpMethod" : "POST",
"uri" : aws_lambda_function.dss_lambda.invoke_arn,
"passthroughBehavior" : "when_no_match",
"timeoutInMillis" : 29000
}
}
}
},
"components" : {
"schemas" : {
"Empty" : {
"title" : "Empty Schema",
"type" : "object"
}
}
}
})
name = var.project
binary_media_types = ["*/*"]
}
I have spent far too long googling, changing, deploying, all for a favicon. Any advice would be welcome.
本文标签: pythonFavicon not loading from Flask LambdaStack Overflow
版权声明:本文标题:python - Favicon not loading from Flask Lambda - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736652472a1946173.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论