Gradio
Creating a Gradio Live App on MINEO is an easy and effective way to deploy interactive web applications. Follow these steps to set up your own Gradio Live App:
Step 1: Create the app.py File
Begin by creating a file named app.py in your project directory. Keep in mind that the paths in the entrypoint will be relative to the Live App's folder. This file will contain the essential code for your Gradio application. Here's a simple starting example:
import gradio as gr
def greet(name):
return f"Hello, {name}!"
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
if __name__ == "__main__":
demo.launch(show_api=True, server_name="0.0.0.0", server_port=8000, debug=True, strict_cors=False)
This code sets up a basic Gradio app that greets users by their name. You can expand upon this with more functionality as needed.
Step 2: Set Up a New Live App
Next, you need to set up a new Live App on MINEO and define an entrypoint command. This command will launch your application within the Live App environment.
Here's the basic structure for the entrypoint command:
pip install gradio && python app.py
Adding Dependencies
If your app requires additional packages, you can include them using either of these methods:
-
Direct
pip install: Include necessary packages directly in the entrypoint command.pip install gradio numpy pandas && python app.py -
Using
requirements.txt: List your dependencies line by line in arequirements.txtfile and use it in the entrypoint command.pip install -r requirements.txt --no-cache-dir && python app.py
Example requirements.txt:
gradio
numpy
pandas
Configuration Needed to Share Your App
Important Launch Settings
When launching your Gradio app, it's crucial to use specific settings to ensure accessibility through MINEO:
- Server Name: Set
server_nameto"0.0.0.0"to make your app accessible externally. - Port: Set
server_portto8000.
demo.launch(show_api=True, server_name="0.0.0.0", server_port=8000, debug=True, strict_cors=False)
Launch and Share Your Live App
Once you have completed your app.py and entrypoint command, click the Execute button. This will deploy your Gradio application, making it accessible.
Now, you're ready to share your Live App URL and begin developing in a stable and secure environment on the MINEO platform. Enjoy your Gradio Live App!