Well I tried this by testing user agent but it passes the test and the page
loads correctly, which it shouldn't in this example.
Am I meant to pass 'app' as such? I am not sure of this parameter.
Here is my code
from webob import Response
class AntiCurlMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
ua = os.environ.get('HTTP_USER_AGENT', "unknown")
sindex = string.find(ua,'Win',0)
if sindex > 0:
resp = Response('Too many requests!')
resp.status_code = 423
return resp(environ, start_response)
return self.app(environ, start_response)
def webapp_add_wsgi_middleware(app):
return AntiCurlMiddlewarey(app)
On Wednesday, August 1, 2012 4:43:58 PM UTC-4, Kate wrote:
>
> I am getting tens of thousands of curl requests - many thousands time
> browser requests and I want to block them. I'm using python. They coming
> from many different IPs most in Europe. If I can't stop them I will have
> to close my site or go to a new provider.
>
> Thank in advance,
>
> Kate
>
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-appengine/-/kRNatAqarF8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.