Temporary files are a constant source of headaches due to different rules
An alternative strategy for loading the index page is to do it dynamically with a javascript function, instead of having python generate the index.html and write it.
This would cause a slowdown by the dynamic loading, but it could possibly be trivial.