File size: 754 Bytes
74b60dd d3536e2 74b60dd 72cd03d 74b60dd 72cd03d 74b60dd 2355fff 74b60dd d3536e2 9e433d3 |
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 |
from flask import Flask, request, jsonify, send_from_directory
import os
app = Flask(__name__)
@app.route('/')
def index():
return send_from_directory('.', 'index.html')
@app.route('/<path:path>')
def static_files(path):
return send_from_directory('.', path)
@app.route('/log', methods=['POST'])
def log_action():
action_log = request.get_json()
log_file_path = os.path.join(app.root_path, 'user_actions.json')
try:
with open(log_file_path, 'a') as f:
f.write(f"{action_log}\n")
except Exception as e:
print(f"Error writing to log file: {e}")
return jsonify({"status": "success"}), 200
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=int(os.environ.get("PORT", 8080)))
|