From c54e5da19d27624460e21f4918b048ed9cf463dd Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Wed, 13 Feb 2019 00:55:24 +0100 Subject: [PATCH] genericity: send any text --- README.md | 2 +- main.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bfea74c..b62726e 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,5 @@ docker-compose up -d ## Test ``` -curl -d '{"name":"toto", "url":"http://radio.localhost/map/#44", "key": "secret"}' wwm.localhost +curl -d '{"text":"new contrib from toto: http://radio.localhost/map/#44", "key": "secret"}' wwm.localhost ``` diff --git a/main.py b/main.py index 9f3f0fd..31cdd8d 100755 --- a/main.py +++ b/main.py @@ -42,12 +42,12 @@ class WWMBotForwarder(BaseHTTPRequestHandler): """ length = int(self.headers.get('Content-Length')) data = json.loads(self.rfile.read(length).decode()) - status = 'I need a json dict with name, url, key' - if all(key in data for key in ['name', 'url', 'key']): + status = 'I need a json dict with text & key' + if all(key in data for key in ['text', 'key']): status = 'wrong key' if data['key'] == API_KEY: status = 'OK' - self.server.room.send_text(f'Nouvelle demande de {data["name"]}: {data["url"]}') + self.server.room.send_text(data['text']) self.send_response(200 if status == 'OK' else 401) self.send_header('Content-Type', 'application/json')