"Are you a human" type of page in django
In order to prevent DOS type of attacks to my django site, I am considering to show a Captcha page if my web app things it is hit by a certain IP too often. Similar to what SO i开发者_StackOverflow社区s doing when you show too mach activity.
How is the best way to do that in django? My initial ideas so far are
- A decorator in front of every view
- A custom django middleware
What would you suggest? Maybe there exist already django apps for that?
You are right, there are existing Django Apps which do this. Try to "design" (not code) the whole thing yourself & then look at how these apps are implemented. You'll learn this way. Here are the links
- django-simple-captcha
- django-captcha
- django captcha & images
A custom middleware would be best. If I understood your requirements, you want to both log how often the IP hits the web app and then to show the Captcha page for authorization.
Keep in mind that this will keep Google and other search engine bots out as well if you won't add anything to deal with them specifically (e.g. User agent checking etc).
精彩评论