storage / app.py
mike23415's picture
Create app.py
c0ac8ca verified
raw
history blame contribute delete
985 Bytes
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)