pyramidでfavicon.icoを出力する
httpsでアクセスするサイトを作っているんですが、 favicon.icoだけ、redirectしていたら、 そこだけ http 扱いと判定されてしまい、 browser で warning がでてしまいました。
redirectはやめて、ファイルで出力します。
https://pyramid-cookbook-stevepiercy.readthedocs.io/en/latest/static_assets/files.html
この情報から下のように書きました。:
def favicon(request): # view_config {{{1
# type: (Any) -> FileResponse
path = os.path.join(
os.path.dirname(__file__), "statics", "favicon.ico")
ret = FileResponse(path, request=request, content_type="image/x-icon")
return ret
favicon = view_config(route_name="favicon")(favicon)
実際には、下のような構造になっているんで、問題なさそうなんですけどね...:
browser -- nginx -- pyramid
コメント
Comments powered by Disqus