ConstantCoder's picture
Update app.py
72cd03d verified
raw
history blame
867 Bytes
from flask import Flask, request, jsonify
from sklearn.tree import DecisionTreeClassifier
import numpy as np
app = Flask(__name__)
# Basit örnek veriler (Bu veriler yerel olarak tutulabilir)
# Örnek veri formatı: [phishing_response, ransomware_response, ddos_response, malware_response]
example_data = [
[0, 0, 1, 1],
[1, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 1]
]
# Örnek sonuçlar: 1 = güvenli, 0 = güvensiz
example_labels = [1, 0, 1, 0]
# Model eğitimi
model = DecisionTreeClassifier()
model.fit(example_data, example_labels)
@app.route('/analyze', methods=['POST'])
def analyze():
data = request.json
response = [data['phishing'], data['ransomware'], data['ddos'], data['malware']]
prediction = model.predict([response])
return jsonify({'prediction': int(prediction[0])})
if __name__ == '__main__':
app.run(debug=True)