0👍
You need to write the animation to disk and then serve it up via some static interface. Here is an idea of how to accomplish it:
Make your webserver point /animations to /var/www/animations
Save your animations in that folder (You can save mp4 and use HTML5 but if you want to save a GIF this SO has information on what is needed. You could use a model to hold initializing parameters and a hash of those (which would make a decent filename).
Render it in your templates with a regular img tag (or video tag if you use mp4).
Source:stackexchange.com