OwO-Network / DeepLX

Powerful Free DeepL API, No Token Required
https://ssa.sx/deeplx
MIT License
6.68k stars 534 forks source link

Can't get result from sample code #144

Closed wshcdr closed 2 months ago

wshcdr commented 2 months ago

I followed sample codes like following //////////////// import httpx, json

deeplx_api = "http://127.0.0.1:1188/v1/translate"

data = { "text": "Hello World", "source_lang": "EN", "target_lang": "ZH" }

post_data = json.dumps(data) r = httpx.post(url = deeplx_api, data = post_data).text print(r)

/////////////////////// however, r is null

and I wrote my own //////////////////// import requests, json

url = "http://127.0.0.1:1188/translate"

data = { "text": "Hello world!", "source_lang": "EN", "target_lang": "ZH" } post_data = json.dumps(data)

response = requests.post(url, data=post_data)

dic = response.json() print(dic['data']) //////////////////// it worked fine, don't why?

missuo commented 2 months ago

pls read docs carefully.