Commit 5d946fff authored by Mindiell's avatar Mindiell

Ok, testing return code for API is fixed (2)

parent 7c96c2b8
......@@ -338,7 +338,6 @@ class Rp():
# Do the same for new RP
Log.debug("Adding article to new RP")
headers = {"Authorization": config.token}
data = {
"url": url,
"speak": True if "c" in command else False,
......@@ -346,11 +345,15 @@ class Rp():
"quote": True if command.count("p") > 1 else False,
}
Log.debug(data)
result = requests.post(
"%s/articles/" % config.api,
data=data,
headers=headers
)
try:
result = requests.post(
"%s/articles/" % config.api,
data=data,
headers={"Authorization": config.token},
)
except Exception as e:
Log.error("Erreur lors de l'appel à l'API : " + str(e))
Log.debug(result.status_code)
if result.status_code>=200 and result.status_code<300:
article = json.loads(result.text)
note = article["score"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment