demo_requests_delete_allow_redirects.py:
import requests url = 'https://w3schools.com/python/demopage.php' #Sometimes the server redirects a request, could be if the file does not exist etc., set the 'allow_redirects' parameter to False to deny redirects: x = requests.delete(url, allow_redirects=False) #print the response text (the content of the requested file): print(x.text)
C:\Users\My Name>python demo_requests_delete_allow_redirects.py
<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found <a HREF="https://www.w3schools.com/python/demopoage.php">here</a></body>