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 <[email protected]> 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
>  
> <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
>  
> <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
>  
> <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 [email protected] 
> <mailto:[email protected]>.
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/1F9C7B1F-32EC-4FDB-B700-13F2700E302C%40gmail.com.

Reply via email to