jason-ai-twin / Emily_Knowledge_Base.py
jlind456's picture
Initial upload of Qwen AI twin weights
9507c73 verified
Raw History Blame Contribute Delete
761 Bytes
from flask import Flask, request, jsonify
import os
app = Flask(__name__)
AUTHORIZED_DIR = os.path.expanduser("~/robot_share/")
@app.route('/save_memory', methods=['POST'])
def save_memory():
data = request.json
filename = data.get('filename')
content = data.get('content')
# SECURITY GATEKEEPER:
# Only allow files within robot_share, prevent directory traversal
safe_filename = os.path.basename(filename)
full_path = os.path.join(AUTHORIZED_DIR, safe_filename)
with open(full_path, "w", encoding="utf-8") as f:
f.write(content)
return jsonify({"status": "success", "file": safe_filename})
if __name__ == '__main__':
# Run this on your local network
app.run(host='0.0.0.0', port=5000)