This is the route on app.py
app.route('/analyze', methods=['POST'])
async def analyze(requestArg):
img_data = await requestArg.form()
img_bytes = await (img_data['file'].read())
img = open_image(BytesIO(img_bytes))
prediction = learn.predict(img)[0]
result(str(prediction))
I'm trying to send the str(prediction) to the result() function on static/js/script.js here
function result(str) {
$(".pd-result").show();
var resultText = $(".text")
switch (str) {
case "emotion":
text.html("angry");
break;
default:
break;
}
};
I've tried to just directly call result(str(prediction)) but it doesn't work.
$.post()to make a request to the server's/analyzeroute, then process the result in the success callback.