mirror of
https://github.com/bsedin/matrix-webhook.git
synced 2026-04-09 11:25:40 +00:00
decode json from the HTTP request, and post it to the room
This commit is contained in:
4
main.py
4
main.py
@@ -10,6 +10,7 @@ Needs the following environment variables:
|
|||||||
- MMW_BOT_ROOM_ID: the room on which send the notifications
|
- MMW_BOT_ROOM_ID: the room on which send the notifications
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
|
|
||||||
@@ -44,6 +45,9 @@ class WWMBotForwarder(BaseHTTPRequestHandler):
|
|||||||
"""
|
"""
|
||||||
main method, get a json dict from wifi-with-me, send a message to a matrix room
|
main method, get a json dict from wifi-with-me, send a message to a matrix room
|
||||||
"""
|
"""
|
||||||
|
length = int(self.headers.get('Content-Length'))
|
||||||
|
data = json.loads(self.rfile.read(length).decode())
|
||||||
|
self.server.matrix_room.send_text(f'Got a request on {self.path}: {data}')
|
||||||
self.ret_ok()
|
self.ret_ok()
|
||||||
|
|
||||||
def ret_ok(self):
|
def ret_ok(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user