mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
37 lines
710 B
JavaScript
37 lines
710 B
JavaScript
|
|
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(() => {
|
|
$("#textbox-output").val(event.data);
|
|
})
|
|
|
|
}
|
|
} catch (e) {
|
|
notifyError(e)
|
|
}
|