djangosnippets.org: Latest snippets posted by jensbreithttps://djangosnippets.org/users/jensbreit/2008-09-24T04:07:29.008999-05:00jensbreitDecorator to limit request rates to individual views
2008-09-24T04:07:29.008999-05:00jensbreithttps://djangosnippets.org/snippets/1083/<p>Example:</p>
<pre><code>@limit("global", 3, 10, per_ip=True)
def view(request, ...):
</code></pre>
<p>The example limits the view to one request every 3 seconds per ip address. The limit is shared by every view that uses the string "global" (first parameter), which is an arbitrary string. Request succeed until the accumulated requested time in seconds …</p>
Freely redistributableImage gradients on the fly
2008-06-06T09:45:29.761663-05:00jensbreithttps://djangosnippets.org/snippets/787/<p>A Django view to create an image gradient on the fly as a PNG file. The direction, size and colors of the gradient a specified in the filename and extracted by Django in the urls.py.</p>
<p>Example usage from CSS:
<code>background: url(/gradient-down-255,255,255-to-0,0,0-70-of-120.png) repeat-x;</code> creates a 70-pixel vertical gradient as background from …</p>
Freely redistributable