mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
44 lines
920 B
JavaScript
44 lines
920 B
JavaScript
var predict_div = $("#predict_div").val();
|
|
|
|
function notifyError(error) {
|
|
$.notify({
|
|
// options
|
|
message: 'Not able to communicate with model (is python code still running?)'
|
|
},{
|
|
// settings
|
|
type: 'danger',
|
|
animate: {
|
|
enter: 'animated fadeInDown',
|
|
exit: 'animated fadeOutUp'
|
|
},
|
|
placement: {
|
|
from: "bottom",
|
|
align: "right"
|
|
},
|
|
delay: 5000
|
|
|
|
});
|
|
}
|
|
|
|
try {
|
|
ws.onerror = function(evt) {
|
|
notifyError(evt)
|
|
};
|
|
|
|
ws.onmessage = function (event) {
|
|
console.log(event.data);
|
|
sleep(300).then(() => {
|
|
if (event.data.length == 1) {
|
|
$("#predict_div").css({ 'font-size':'300px'});
|
|
} else {
|
|
$("#predict_div").css({ 'font-size':'60px'});
|
|
}
|
|
$("#predict_div").text(event.data);
|
|
})
|
|
|
|
}
|
|
} catch (e) {
|
|
notifyError(e)
|
|
}
|
|
|