I'm trying to invoke my test hello huggingface app via API:
import gradio as gr
def greet(name):
return "Hello " + name + "!!"
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()
I'm able to do this by using the gradio client API:
from gradio_client import Client
client = Client("https://toromanow-test2.hf.space/") result = client.predict( "John", # str representing input in 'name' Textbox component api_name="/predict" ) print(result)
But I'm unable to invoke it by submitting the POST request directly:
curl -d '{ "data": "John"}' -H "Content-Type: application/json" -X POST https://toromanow-test2.hf.space/api/predict
Errors out with:
{"detail":[{"loc":["body","data"],"msg":"value is not a valid list","type":"type_error.list"}]}
I've experimented with diferent formats but can't figure out the one what works.