On Dec 10, 4:45 pm, Mark Freeman <mark.allen.free...@gmail.com> wrote:
> I have recently created a python module which parses an input string
> and invokes the program lilypond to generate a music score image. All
> of this works fine as a standalone python app. I'm now looking to add
> this to my django site so users can enter the  text on a form, hit
> submit, and have the site return the image of the music score.
>
> The form submission part is no problem, but I am not sure where to
> start with having the view return the image to the page. Anyone have
> suggestions for where to start?

An HttpResponse can contain whatever you like - it doesn't just have
to return HTML. So you can use it quite happily to return raw JPG or
PNG or whatever you want. Just set the mimetype to the correct type
when you initialise it.

Also remember that HttpResponse is a file-like object, so you can pass
it into anything that expects to write to a file.

Here for example is a very old post by Jacob that shows how to use
this to produce dynamic graphical headlines:
http://jacobian.org/writing/improved-text-image-view/
--
DR.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to