working server/client

This commit is contained in:
2025-01-30 15:40:24 +01:00
parent 6650f0e042
commit 20ede6e02a
3 changed files with 14 additions and 13 deletions

View File

@@ -7,8 +7,11 @@ import random
app = Flask(__name__)
hooks = {}
hooks['2345555XE'] = '#Bottest'
def sendmessage(target, message):
print("Sendmessage called")
print("Sendmessage %s called to %s" % (message, target))
uri = "ws://localhost:5080"
#message = "#Bottest Hello, world!"
msg = ("%s %s" % (target, message))
@@ -28,18 +31,19 @@ def sendmessage(target, message):
print(response)
return response
@app.route('/webhook', methods=['POST'])
def webhook_receiver():
@app.route("/webhook/<id>", methods=['POST'])
def webhook_receiver(id):
print("Webhook id %s" % (id))
data = request.json # Get the JSON data from the incoming request
# Process the data and perform actions based on the event
print("Received webhook data:", data)
target = hooks.get(id)
print(target)
sendmessage(target, data.get('message'))
return jsonify({'message': 'Webhook received successfully'}), 200
@app.route('/webhook', methods=['GET'])
def webhook_test():
print("Sending test")
sendmessage('#Bottest', 'Testing 123')
return jsonify({'message': 'Webhook received successfully'}), 200
if __name__ == '__main__':
app.run(debug=True)