Forums

How to blacklist or block requests from a particular IP on my flask app?

So, I'm getting too many requests from this IP address 35.232.148.181. I want to ban or block requests from it. It made 68485 requests this month and more than 84000 requests the previous month.

I'm using this code to ban IP addresses and I tested it on my self and it is not working. https://pastebin.com/mEf4LZd2

Could you please tell me how to fix it?

That isn't working because you are not looking at the correct header. See https://help.pythonanywhere.com/pages/WebAppClientIPAddresses/