gradio-space-ci / app.py
Wauplin's picture
Wauplin HF staff
first commit
0fc235e
raw history blame
No virus
1.48 kB
#!/usr/bin/env python
from pathlib import Path
import gradio as gr
from gradio_space_ci import configure_space_ci
def greet(name: str) -> str:
return "Hello " + name + "!"
with gr.Blocks() as demo:
gr.Markdown("## Dummy gradio app to showcase gradio-space-ci")
name = gr.Textbox(label="Name")
output = gr.Textbox(label="Output Box")
greet_btn = gr.Button("Greet")
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
with gr.Blocks() as demo_with_readme:
with gr.Tab("README"):
gr.Markdown(Path("README.md").read_text().split("---")[-1])
with gr.Tab("Demo"):
demo.render()
if __name__ == "__main__":
configure_space_ci(
blocks=demo_with_readme.queue(), # ANY gradio app
trusted_authors=["clefourrier"], # space owners + manually trusted authors
private="auto", # ephemeral spaces will have same visibility as the main space. Otherwise, set to `True` or `False` explicitly.
variables="auto", # same variables as the main space. Otherwise, set to a `Dict[str, str]`.
secrets=["HF_TOKEN"], # which secret do I want to copy from the main space? Can be a `List[str]`.
hardware=None, # "cpu-basic" by default. Otherwise set to "auto" to have same hardware as the main space or any valid string value.
storage=None, # no storage by default. Otherwise set to "auto" to have same storage as the main space or any valid string value.
).launch()