Browse Source

genericity: send any text

Guilhem Saurel 6 years ago
parent
commit
c54e5da19d
2 changed files with 4 additions and 4 deletions
  1. 1 1
      README.md
  2. 3 3
      main.py

+ 1 - 1
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
 ```

+ 3 - 3
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')