Dalsza praca nad integracją
This commit is contained in:
parent
599a4ce252
commit
6cb9ffc781
@ -190,6 +190,8 @@ const Hero = () => {
|
||||
ball.style.left = x + "%"
|
||||
ball.style.top = y + "%"
|
||||
}
|
||||
//var shooterX = konwerturX(ball.style.left)
|
||||
//var shooterY = konwetujY(ball.style.top)
|
||||
posytion.innerHTML = "x:" + konwerturX(ball.style.left) + "m " + "y:" + konwetujY(ball.style.top) + "m";
|
||||
bojo.addEventListener("mouseup", function(){
|
||||
ball.style.background = pColor
|
||||
@ -204,20 +206,29 @@ const Hero = () => {
|
||||
// // Wyłanie zapytania do serwera
|
||||
function sentQuestion() {
|
||||
var ball = document.querySelector('.football');
|
||||
if (ball) {
|
||||
fetch("http://127.0.0.1:5000/get_model").then(
|
||||
res=> res.json()
|
||||
).then(
|
||||
data => {
|
||||
setData(data)
|
||||
console.log(data)
|
||||
}
|
||||
)
|
||||
eX = data.response
|
||||
document.getElementById("ex").innerHTML = "Współczynnik xG: "+ eX
|
||||
} else {
|
||||
alert('Piłka nie jest obecnie na boisku.');
|
||||
}
|
||||
|
||||
if (ball) {
|
||||
// Użyj backticksów zamiast zwykłych cudzysłowów
|
||||
//console.log('Wysyłanie wartości: ', ball);
|
||||
shooterX = konwerturX(ball.style.left)
|
||||
shooterY = konwetujY(ball.style.top)
|
||||
console.log('Wysyłanie wartości: ', shooterX, shooterY);
|
||||
fetch(`http://127.0.0.1:5000/get_model?x=${shooterX}&y=${shooterY}`).then(
|
||||
res => res.json()
|
||||
).then(
|
||||
data => {
|
||||
setData(data);
|
||||
console.log(data);
|
||||
// Przenieś tę linię do środka bloku .then(), aby uniknąć błędów
|
||||
let eX = data.response;
|
||||
document.getElementById("ex").innerHTML = "Współczynnik xG: " + eX;
|
||||
}
|
||||
).catch(error => {
|
||||
console.error('Błąd:', error);
|
||||
});
|
||||
} else {
|
||||
alert('Piłka nie jest obecnie na boisku.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from flask import Flask
|
||||
from flask import Flask, request, jsonify
|
||||
from flask_cors import CORS
|
||||
from modele.modele import LogisticRegression_predict_proba
|
||||
|
||||
@ -15,14 +15,21 @@ app.config['CORS_HEADERS'] = 'Content-Type'
|
||||
# zapytanie o regresje logistyczną na podstawie pozycji piłki
|
||||
|
||||
# @app.route("/LRegresion<x>&<y>")
|
||||
@app.route("/get_model")
|
||||
@app.route("/get_model", methods = ['GET'])
|
||||
def get_model():
|
||||
|
||||
#x = int(x[0:2])
|
||||
#y = int(y[0:2])
|
||||
# x = int(x[0:2])
|
||||
# y = int(y[0:2])
|
||||
x = request.args.get('x', type=float)
|
||||
y = request.args.get('y', type=float)
|
||||
## change model on xgboost
|
||||
## add angle, match minutes and number of players
|
||||
|
||||
response = LogisticRegression_predict_proba(position_x=5,
|
||||
position_y=5,
|
||||
if y is None and x is None:
|
||||
return jsonify({"error": "Brak wymaganych parametrów"}), 400
|
||||
|
||||
response = LogisticRegression_predict_proba(position_x=x,
|
||||
position_y=y,
|
||||
angle = 13.67,
|
||||
match_minute=13,
|
||||
Number_Intervening_Opponents=3,
|
||||
@ -33,7 +40,8 @@ def get_model():
|
||||
#print(y)
|
||||
#print(response)
|
||||
res = str(response)
|
||||
return {"response":res}
|
||||
#return {"response":res}
|
||||
return jsonify({"response":res})
|
||||
|
||||
# uruchomienie serwera
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user