Here is what I include in the dynamic html to reference the css file and 2 javascript files:
- Code: Select all
html_elems.append ("<head>\n")
html_elems.append ('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n')
html_elems.append("<title>Indigo log viewer</title></Head>\n")
html_elems.append('<link rel="stylesheet" type="text/css" href="css/EventLog.css">')
html_elems.append ('<meta name="apple-mobile-web-app-capable" content="yes">')
html_elems.append ('<meta name="viewport" content="width=320,initial-scale=0.8,maximum-scale=1.6,user-scalable=yes"/>')
html_elems.append("<body>\n")
html_elems.append ('''<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/tablekit.js"></script>''')
Then when the server defaulted to json as the content type even though different content-types were specified, I added this at the end to specify a header with text/html:
- Code: Select all
html_elems.append("</body>\n")
#html_elems.append("</html>\n")
#indigo.server.log("html_elems = " + str(html_elems))
#content_type = indigo.utils.FILE_EXTENSION_MIME_MAP.get(os.path.splitext(indigo_path[-1])[-1].strip("."), "text/html")
reply = indigo.Dict()
reply["headers"] = indigo.Dict({"Content-Type": "text/html"})
reply["content"] = ''.join(html_elems)
return reply
The problem is that I don't know how to specify different content types for each of the referenced files. I thought that is what the type specs are for but apparently not. This approach did work with the older IWS.
The oddest thing is that when I save the resulting file as a html file and serve it directly, the referenced style sheet works fine. I don't know what the difference is between serving the python constructed dynamic html versus serving the html file static file resulting from that dynamic html..
I was able to get it working partially by including the styles inline with the <style> tag but that approach didn't work with the javascript and was unwieldy due to the size of the file.
Thanks, Matt
--Dave