Adding 'rb' parameter to open method fixed the issue.

Thank you

On Sat, 14 Mar 2020 at 14:50, Michael Merickel <mmeri...@gmail.com> wrote:

> The unicode issue is just due to opening the file in unicode mode (the
> default in python 3) and then setting the result to body (which expects
> bytes). Modify the open calls to use open(..., 'rb') and it should work.
>
> On Mar 14, 2020, at 11:16, Sydo Luciani <sydo.luci...@gmail.com> wrote:
>
> Procedure to serve favicon.ico from root:
>
> https://docs.pylonsproject.org/projects/pyramid-cookbook/en/latest/static_assets/serving-files.html#serving-a-single-file-from-the-root
>
> Throws error:
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9e in position 34:
> invalid start byte
>
> Apparently open().read() can't decode favicon.ico.
>
> Has any one had success with this procedure ?
>
> I had to change the favicon_view to return "FileResponse" object to make
> it work:
>
> https://docs.pylonsproject.org/projects/pyramid-cookbook/en/latest/static_assets/serving-files.html#serving-file-content-dynamically
>
> somehow the .rst file on github not showing the code that shows in .html
> or in .raw file:
>
> https://github.com/Pylons/pyramid_cookbook/blob/master/docs/static_assets/serving-files.rst#serving-a-single-file-from-the-root
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/6aab8e65-007a-48e4-b400-41af3fa26623%40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/6aab8e65-007a-48e4-b400-41af3fa26623%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pylons-discuss+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pylons-discuss/1F9C7B1F-32EC-4FDB-B700-13F2700E302C%40gmail.com
> <https://groups.google.com/d/msgid/pylons-discuss/1F9C7B1F-32EC-4FDB-B700-13F2700E302C%40gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAJspodgyj5u6t6RAPFDtaawRi1kFbHqs9c%2BR8jdVsdUSnekuZA%40mail.gmail.com.

Reply via email to