We can use python httpx library to send http get or post request. However, you may get Response [504 Gateway Time-out] error. In this tutorial, we will introduce you how to fix it.
Look at the example:
import httpx url = 'http://x.x.x.x:33721/tuling/asrc/v3/process data ={ "id":"123321233", "audio":{"aid":"aaa","bits":16, "chnl":1, "encoding":1,"offset":0,"rate":8000,"spnk":1,"uri":"http://x.x.x.x/record/v4/72e68a48-350f-4c68-839b-15dc0a3cd06b.wav"} } timeout = httpx.Timeout(None) headers = {'Content-Type': 'application/json'} r = httpx.post(url, json=data, timeout= timeout,headers = headers) print(r)
Run this code, you will get:
<Response [504 Gateway Time-out]>
How to fix this gateway time-out error?
We can use python requests package instead of httpx.
For example:
import requests r1 = requests.post(url, json=data) print(r1.text)
Then, run this code, you will find this gateway time-out error disappeared.