I want to transfer data from Javascript to mysql via flask, how to do it? In the below code, I calculate scores from the quiz and i want to post it in mysql database using flask
quiz.js
const lastQuestion = questions.length - 1;
let runningQuestion = 0;
let c1=0;
let c2=0;
let c3=0;
let c4=0;
let scorepos=0;
let scoreneg=0;
function storeAnswer(answer){
if( answer == questions[runningQuestion].choice1){
c1++;
}else if( answer == questions[runningQuestion].choice2){
c2++;
}else if( answer == questions[runningQuestion].choice3){
c3++;
}else if( answer == questions[runningQuestion].choice4){
c4++;
}
scorepos=c1+c2;
scoreneg=c3+c4;
console.log(c1);
if(runningQuestion < lastQuestion){
runningQuestion++;
return renderQuestion();
}else{
graphRender(scorepos,scoreneg);
scoreRender(c1,c2,c3,c4);
renderAnalysis(scorepos,scoreneg,c1,c2,c3,c4)
score1.innerHTML = "<p>C1:"+ c1 +"</p>";
score2.innerHTML = "<p>C2:"+ c2 +"</p>";
score3.innerHTML = "<p>C3:"+ c3 +"</p>";
score4.innerHTML = "<p>C4:"+ c4 +"</p>";
}
}
the calculation is done in js, i want to push it into mysql via flask. Node.js cannot be used so is there any other method?