launch is the Gradio method that starts a configured application and makes its interface available for interaction. With Interface, it opens a local URL, commonly http://127.0.0.1:7860. section 10.1.1
Listing 10.1 A simple Gradio example
import gradio as gr
def my_chatbot(message):
return "Hello, " + message
interface = gr.Interface(fn = my_chatbot, #1
title = "Hello, Gradio!", #2
inputs = "text", #3
outputs = "text") #4
interface.launch()
A minimal runnable application binds Interface to my_chatbot and finishes by calling interface.launch(). section 10.1.1
Configure launch and its surrounding application with these options and operating notes:
- Set share=True to create a temporary public link; the running notebook kernel or Python process must remain active. section 10.1.5
- Use launch() after defining components and events inside a Blocks context for a more customized chatbot interface. section 10.3
- Shared links expire after 72 hours; Hugging Face Spaces provides a more persistent public-hosting route. section 10.1.5
