| | from flask import Flask, request, jsonify |
| | from flask_cors import CORS |
| | import uuid |
| | import time |
| |
|
| | app = Flask(__name__) |
| | CORS(app) |
| |
|
| | |
| | LOG_STORE = {} |
| |
|
| | @app.route("/api/log", methods=["POST"]) |
| | def store_log(): |
| | try: |
| | data = request.json |
| | log_id = str(uuid.uuid4()) |
| | LOG_STORE[log_id] = { |
| | "ip": data.get("ip"), |
| | "location": data.get("location"), |
| | "message": data.get("message"), |
| | "timestamp": time.time(), |
| | "label": data.get("label") |
| | } |
| | return jsonify({"status": "stored", "id": log_id}) |
| | except Exception as e: |
| | return jsonify({"error": str(e)}), 400 |
| |
|
| | @app.route("/api/logs", methods=["GET"]) |
| | def get_logs(): |
| | return jsonify(LOG_STORE) |
| |
|
| | @app.route("/") |
| | def home(): |
| | return "✅ Flagged Chat Log Store is Running" |
| |
|
| | if __name__ == "__main__": |
| | app.run(host="0.0.0.0", port=7860) |