Http Redirection code 3XX in python requests

requests handles redirects for you, see redirection and history. Set allow_redirects=False if you don’t want requests to handle redirections, or you can inspect the redirection responses contained in the r.history list. Demo: >>> import requests >>> url=”https://httpbin.org/redirect-to” >>> params = {“status_code”: 301, “url”: “https://stackoverflow.com/q/22150023”} >>> r = requests.get(url, params=params) >>> r.history [<Response [301]>, <Response [302]>] … Read more

Authorization in RESTful HTTP API, 401 WWW-Authenticate

To answer your questions: How to deal with unauthorized requests? The way you described it is pretty much the recommended way for a RESTful service. As far as I can see there is absolutely nothing wrong with that. What WWW-Authenticate header should 401 responses supply? In general the WWW-Authenticate header tells the client what kind … Read more

3rd party API gives back 500 error, what code should my API return

Well, I think it’s up to you which error code you’ll use. But if the actual functionality of your API depends on a third-party API, I would consider using the HTTP code 503 Service Unavailable, because your service will be unavailable until the third-party API works, no matter what HTTP code the third-party API returned. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)