import gradio as gr
# Reads /info from the browser, exactly as an API client would, and renders the
# advertised default with a plain . Both details matter: fetching from the
# client means the Host header is the real public host, and an
is loaded
# by the browser rather than downloaded by the server.
PHOTO = "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/cheetah1.jpg"
SHOW_ADVERTISED_DEFAULT = """
async () => {
const BUS = "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png";
const info = await (await fetch("gradio_api/info")).json();
const d = info.named_endpoints["/describe"].parameters[0].parameter_default || {};
const url = d.url || "";
const broken = url === BUS;
const img = url
? `
`
: "no default advertised";
const verdict = broken
? `
/info advertises a bus —
Image.example_payload() standing in for the default. A client
calling /describe without the photo argument
fetches the wrong file.
/info advertises the cheetah this app
really serves, at an absolute url the client can fetch.
url: ${url}