Hi Mark

On 10/12/09 16:45, Mark Freeman 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?
>   

We're doing something similar with generating maps.

We have a model to represent the generated map to record a hash of its
creation parameters (e.g. dimensions, points plotted) and when it was
generated. The map is then saved to a cache directory with the hash as a
filename.

We then have a simple view to serve the page:

def generated_map(request, hash):
    map = get_object_or_404(Map, hash=hash)
    f = open(map.get_filename(), 'r')
    return HttpResponse(f, mimetype="image/png")

The alternative would be to stick an Alias in your apache conf (assuming
you're using apache) to serve the files directly from the filesystem.
This solution wouldn't let you perform any authorisation, though.

We remove out old maps when we reach some large number in the cache
directory so as not to fill up the disk.

HTH,

Alex


PS. Sorry Mark for sending this again; my reply-list button seems to
actually be a reply-to-sender button. Silly TB3.04b.

--

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