File size: 985 Bytes
c0ac8ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from flask import Flask, request, jsonify
from flask_cors import CORS
import uuid
import time

app = Flask(__name__)
CORS(app)

# In-memory log store: { id: { ip, location, messages, timestamps } }
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")  # e.g. "Terrorism", "Blackmail"
        }
        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)