Download app.py from ConstantCoder/Cyber-Security-Attack-Simulator: direct link, hf CLI and curl.
- Browser
- Download file 754 Bytes
-
https://huggingface.co/spaces/ConstantCoder/Cyber-Security-Attack-Simulator/resolve/8ce6cafa1dd67ffdf443849fa0b1650cdc9cc18d/app.py
- Command line
-
hf download hf://spaces/ConstantCoder/Cyber-Security-Attack-Simulator@8ce6cafa1dd67ffdf443849fa0b1650cdc9cc18d/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ConstantCoder/Cyber-Security-Attack-Simulator/resolve/8ce6cafa1dd67ffdf443849fa0b1650cdc9cc18d/app.py
754 Bytes
| from flask import Flask, request, jsonify, send_from_directory | |
| import os | |
| app = Flask(__name__) | |
| def index(): | |
| return send_from_directory('.', 'index.html') | |
| def static_files(path): | |
| return send_from_directory('.', path) | |
| 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))) | |