Refine your search:

I'm trying to serve up an SVG image from within an app.

The SVG file is in appserver/static and has a .svg file extension. I'm able to retrieve the file just fine. However, the browser either fails to render the content or renders it as plain text, presumably because SplunkWeb is giving it a Content-Type of text/plain.

Does anyone know how to override the default behaviour and tell SplunkWeb (or CherryPy?) to set the correct Content-Type of image/svg+xml?

asked 08 May '11, 18:33

southeringtonp's gravatar image

southeringtonp ♦
4.5k1215
accept rate: 35%


One Answer:

After beating my head against this for quite a while, the following seems to work if you have at least one custom module being loaded. In the module's python code:

import mimetypes
if not mimetypes.inited:
    mimetypes.init()
mimetypes.add_type('image/svg+xml', '.svg', True)

The upshot is that SplunkWeb is calling cherrypy.lib.static.serve_file(), which according to this page relies in turn on the python mimetypes module.

This still isn't an ideal solution, since it requires mucking about with module python code. Anyone have a more generic approach?

link

answered 09 May '11, 11:43

southeringtonp's gravatar image

southeringtonp ♦
4.5k1215
accept rate: 35%

edited 09 May '11, 20:42

Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×27
×2
×2
×1
×1

Asked: 08 May '11, 18:33

Seen: 826 times

Last updated: 09 May '11, 20:42

Copyright © 2005-2012 Splunk, Inc. All rights reserved.