What I’m trying to do:
I have a google colab notebook which as a API that I defined and running on anvil server.
Create anvil webapp with simple form having file input and submit button. I have edited click event and added code to call google colab api using anvil.server.call("api_name’, parameters) and I am able to see the response.
Created another anvil app with custom html and javascript and calling the above google colab api using same anvil.server.call(“api_name”, parameters).
What I’ve tried and what’s not working:
It is throwing error saying call is undefined.
Code Sample:
# this is a formatted code snippet.
# paste your code between
** Custom html script block **
reader.onload = function(e) {
var fileContent = e.target.result;
console.info("Processing fileContent : ", fileContent);
console.info("anvil.server : ", anvil.server);
anvil.server.call(‘process_file’, file.name, fileContent)
.then(function(result) {
document.getElementById(“response”).innerHTML = result;
// Show the response div after receiving the result
document.getElementById(“resultDiv”).style.display = “block”;
})
.catch(function(error) {
document.getElementById(“response”).innerHTML = "Error: " + error;
document.getElementById(“resultDiv”).style.display = “block”;
});
};
**Clone link:**
https://lm5xii6jycw75lq7.anvil.app/YPEQXOGWDPISFEFR756OWELR