0

I am using Sphinx to build a documentation project. I have created this script to watch the directory and trigger a Sphinx build when changes occur:

import os
import sys
from livereload import Server, shell

wd = os.path.dirname(sys.argv[0])

server = Server()

server.watch(wd, shell('make.bat clean && make.bat html', cwd=wd), delay=1)

server.serve(root='../_build/html', port=8000, host='localhost')

This works great, but all web fonts in the theme (ReadTheDocs) are being transferred with Content-Type: text/html and the Chrome developer console shows:

Failed to decode downloaded font: http://localhost:8000/_static/fonts/Lato-Regular.ttf
Failed to decode downloaded font: http://localhost:8000/_static/fonts/fontawesome-webfont.woff?v=4.2.0
Failed to decode downloaded font: http://localhost:8000/_static/fonts/Lato-Bold.ttf
Failed to decode downloaded font: http://localhost:8000/_static/fonts/RobotoSlab-Bold.ttf
Failed to decode downloaded font: http://localhost:8000/_static/fonts/RobotoSlab-Regular.ttf
Failed to decode downloaded font: http://localhost:8000/_static/fonts/fontawesome-webfont.ttf?v=4.2.0

However, a local IIS website pointing to the same directory works just fine. I'm assuming it's an issue with TornadoServer - probably defaulting unknown MIME types to text/html. Does anyone have a solution for this?

I used the ASP.NET Docs as a starting point: https://github.com/aspnet/Docs/. This has the same issue when following their contribution guidelines (using sphinx-autobuild).

Evan Mulawski
  • 54,662
  • 15
  • 117
  • 144

1 Answers1

2

Tornado gets the mime types for static files from the python standard library's mimetypes module. You need to either make sure that your system mimetypes database (normally /etc/mime.types. Your question suggests that you're using Windows, which is not an officially supported platform for Tornado. I have no idea whether Windows even has an equivalent) includes all the file types you want to serve, or supplement it manually with mimetypes.add_type.

Ben Darnell
  • 21,844
  • 3
  • 29
  • 50
  • Awesome! Adding `mimetypes.add_type("application/x-font-woff", ".woff")` and `mimetypes.add_type("application/octet-stream", ".ttf")` to my Python script worked. Thank you. – Evan Mulawski May 28 '15 at 15:06