gradio
gradio copied to clipboard
Javascript client does not support self-hosting endpoint ( not hugging-face space)
The current version of the Javascript client does not support self-hosting endpoints, unlike the Python client that supports it. Therefore, please update the Javascript client. Thank you.
Reproduction
app.py
import gradio as gr
def predict(text):
return 'hello ' + text
gr.Interface(fn=predict, inputs="text", outputs="text").launch()
package.json
{
"name": "gradio_test",
"type": "module",
"version": "1.0.0",
"main": "client.js",
"dependencies": {
"@gradio/client": "^0.1.2"
}
}
client.js
import { client } from "@gradio/client";
async function run() {
const app = await client("https://localhost:7860/", {
status_callback: (res) => {
console.log(res);
},
});
const result = await app.predict("/predict", [
"Howdy!", // string in 'text' Textbox component
]);
console.log(result?.data);
}
run();
run app
python ./app.py
run client
node ./client.js
outputs
{
status: 'error',
message: 'Could not load this space.',
load_status: 'error',
detail: 'NOT_FOUND'
}
dependencies
- pip package: gradio==3.35.2
- npm package: @gradio/[email protected]
I thought it did. Will check this and see what the issue is.
And, if there is an error, the “const app = await client(...)” promise function will wait indefinitely and not return. I think it should throw an exception.
This might be a dumb thing to say, but maybe the issue is with the 's' in 'https'? Instead of "https://localhost:7860/", should it not be "http://localhost:7860/" ?
@manu-sapiens Not a dumb thing to say at all. It is an excellent question.
I've just tested this and it looks like this is working on my end. My app was hosted on http://127.0.0.1:7860
so maybe the protocol was the problem here. @nne998 let me know if this issue persists for you!