Changed http Calls to https, and rename dockercompose to dpocker-compose.yml, Working callbacks

main
key 11 months ago
parent 15f7acb331
commit 86cdadbbdf

@ -10,7 +10,7 @@ services:
networks:
- web
ports:
- 5002:5000
- 5001:5000
labels:
- "traefik.enable=true"
- "traefik.http.routers.iot-callback.rule=Host(`iot.keydev.me`)"

@ -1,12 +1,43 @@
from flask import Flask, request
from flask import Flask, request, jsonify
import json
import os
app = Flask(__name__)
DATA_FILE = 'data.json'
@app.route('/callback', methods=['POST'])
def callback():
data = request.json
# Process the data as needed
if not data:
return jsonify({"error": "Invalid data"}), 400
# Read existing data
if os.path.exists(DATA_FILE):
with open(DATA_FILE, 'r') as f:
stored_data = json.load(f)
else:
stored_data = []
# Append new data
stored_data.append(data)
# Write data back to file
with open(DATA_FILE, 'w') as f:
json.dump(stored_data, f, indent=4)
return 'Callback received', 200
@app.route('/data', methods=['GET'])
def get_data():
if os.path.exists(DATA_FILE):
with open(DATA_FILE, 'r') as f:
stored_data = json.load(f)
else:
stored_data = []
return jsonify(stored_data)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)

@ -0,0 +1,10 @@
[
{
"customerId": "CHE-341216444",
"rcvTime": 1723103768,
"srcImsi": "901405710203483",
"srcIP": "10.128.24.42",
"srcPort": "50000",
"payload": "JAcFgIANH4E="
}
]
Loading…
Cancel
Save