How to share gradio app in my local machine

According to: Sharing Your App in order to share gradio app,
we need to set:
demo.launch(share=True) and we get a share link (https://XXX.gradio.live), which opens ssh tunnel with a machine in us-west.

How can I share my gradio app in my local machine (instead in us-west machine) ?

hi @laro1 , please disable share=False, the default port ie 7860, http://localhost:7860/

In this way I can only access from my local machine.
I want to access from any machine in my local network (i.e: http://10.100.102.105:7860 instead of http://localhost:7860/ ).

How can I do it ?

1 Like

If you are running a gradio โ€˜sdk: gradioโ€™ application, you can set the server_name and server_port in the launch function call of the app.py.

interface.launch(server_name="0.0.0.0", server_port=7860)

3 Likes

Hello @laro1,
Have you figured out a way to share inside local network without using docker?

Hi @saireddy, you donโ€™t need to be running in a docker container. If you run:

Then your app will be available to anyone in your local network. They just need to connect using your host machineโ€™s local IP address

3 Likes

Create certfile:
penssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes

and then:

app.queue().launch(share=False,
                        debug=False,
                         server_name="0.0.0.0",
                         server_port=8433,
                         ssl_verify=False,
                         ssl_certfile="cert.pem",
                         ssl_keyfile="key.pem")

Just an example to clarify the ;

import random
import gradio as gr

def alternatingly_agree(message, history):
    if len(history) % 2 == 0:
        return f"Yes, I do think that '{message}'"
    else:
        return "I don't think so"

gr.ChatInterface(alternatingly_agree).launch(server_name="0.0.0.0", server_port=7860)

In this case I cannot connect to http://localhost:8433/