|
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))) |
|
|