0

So, I have a website in django, how to add restrictions that request to the website can only be made through a browser and not from terminal or scripts.

I want to implement this because in my website I'm using

def ip(request):
    a = request.META.get('HTTP_X_FORWARDED_FOR')
....
  • You check the user agent header (not reliable since people can fake it) and restrict according to that: [How to detect Browser type in Django?](https://stackoverflow.com/questions/2669294/how-to-detect-browser-type-in-django) – Abdul Aziz Barkat Oct 27 '22 at 11:00
  • You can make life slightly non-trivial for scripters if you put cookies in the user's browser when he accesses through one "gateway" view, and then have the views you want to restrict raise Http404 if the cookies are not present and correct. – nigel222 Oct 27 '22 at 16:22

0 Answers0