Praca nad integracją backendu z frontendem

This commit is contained in:
LukaszChrostowski 2024-01-05 22:00:31 +01:00
parent f7b0307112
commit 599a4ce252
6 changed files with 32 additions and 22 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -1,7 +1,7 @@
{
"name": "react_bs_web",
"private": true,
"proxy": "http://localhost:5173",
"proxy": "http://127.0.0.1:5000/",
"version": "0.0.0",
"type": "module",
"scripts": {

View File

@ -10,7 +10,7 @@ const Hero = () => {
const toggleDropdown = () => setIsOpen(!isOpen);
const handleMinuteChange = (e) => setGameMinute(e.target.value);
const [data,setData] = useState([{}])
const [data, setData] = useState("");
//zmienne globalne
//zmienna mówiąca który przycisk jest aktywny, jest ona wykorzystywana
//przez listener nanoszący zawodników na boisko. 1 - strzelec , 2 - bramkarz , 3 - obronca, 4 - napasnik. zmienna przez aktywacje przycskówk bb1, bb2, bb3 i bb4
@ -107,10 +107,10 @@ const Hero = () => {
var pName = "Bramkarz"
var pColor = "#03e7fc"
}else if(possition == 2){
var pName = "Napastnik"
var pName = "Obrońca"
var pColor = "#0324fc"
}else if (possition ==3){
var pName = "Obrońca"
var pName = "Napastnik"
var pColor = "#fc6703"
}
var player = document.createElement('div');
@ -201,13 +201,11 @@ const Hero = () => {
})
}
// Wyłanie zapytania do serwera
// // Wyłanie zapytania do serwera
function sentQuestion() {
var ball = document.querySelector('.football');
if (ball) {
fetch("http://localhost:5173/LRegresion" + shooterX + "&" + shooterY).then(
fetch("http://127.0.0.1:5000/get_model").then(
res=> res.json()
).then(
data => {
@ -222,6 +220,10 @@ const Hero = () => {
}
}
/* Funkcja dodająca listener do boiska*/
function boiskoListener(ev){
ev.preventDefault()
@ -408,7 +410,7 @@ const Hero = () => {
</div>
<div>
<b id = "ex" className="Ex">
</b>
</div>
</div>

View File

@ -13,3 +13,8 @@ def LogisticRegression_predict_proba(position_x, position_y, angle, match_minute
return model.predict_proba(X_new)[0][1].round(2)
#kolejne modele
def xgboost_predict_proba():
model = load('xgboost.joblib')

View File

@ -5,32 +5,35 @@ from modele.modele import LogisticRegression_predict_proba
app = Flask(__name__)
CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
# model Api
@app.route("/members")
def members():
return{"members":["Member1","Member2","Member3"]}
# @app.route("/members")
# def members():
# return{"members":["Member1","Member2","Member3"]}
# zapytanie o regresje logistyczną na podstawie pozycji piłki
@app.route("/LRegresion<x>&<y>")
def LRegresion(x,y):
# @app.route("/LRegresion<x>&<y>")
@app.route("/get_model")
def get_model():
x = int(x[0:2])
y = int(y[0:2])
#x = int(x[0:2])
#y = int(y[0:2])
response = LogisticRegression_predict_proba(position_x=x,
position_y=y,
response = LogisticRegression_predict_proba(position_x=5,
position_y=5,
angle = 13.67,
match_minute=13,
Number_Intervening_Opponents=3,
Number_Intervening_Teammates=0,
isFoot=1,
isHead=0)
print(x)
print(y)
print(response)
return {"response":[str(response)]}
#print(x)
#print(y)
#print(response)
res = str(response)
return {"response":res}
# uruchomienie serwera
if __name__ == "__main__":