Introducing Gradio Clients
WatchIntroducing Gradio Clients
WatchEnvironment variables in Gradio provide a way to customize your applications and launch settings without changing the codebase. In this guide, we'll explore the key environment variables supported in Gradio and how to set them.
GRADIO_SERVER_PORT7860export GRADIO_SERVER_PORT=8000GRADIO_SERVER_NAME"0.0.0.0""127.0.0.1" export GRADIO_SERVER_NAME="0.0.0.0"GRADIO_ANALYTICS_ENABLED"True""True", "False"export GRADIO_ANALYTICS_ENABLED="True"GRADIO_DEBUG0export GRADIO_DEBUG=1GRADIO_ALLOW_FLAGGING"manual""never", "manual", "auto"export GRADIO_ALLOW_FLAGGING="never"GRADIO_TEMP_DIRexport GRADIO_TEMP_DIR="/path/to/temp"GRADIO_ROOT_PATH""export GRADIO_ROOT_PATH="/myapp"GRADIO_SHARE"False""True", "False"export GRADIO_SHARE="True"GRADIO_ALLOWED_PATHS""export GRADIO_ALLOWED_PATHS="/mnt/sda1,/mnt/sda2"GRADIO_BLOCKED_PATHSallowed_paths and all other directories exposed by Gradio by default. Multiple items can be specified by separating items with commas.""export GRADIO_BLOCKED_PATHS="/users/x/gradio_app/admin,/users/x/gradio_app/keys"FORWARDED_ALLOW_IPSuvicorn which is used by Gradio internally. This environment variable is useful when deploying applications behind a reverse proxy. It defines a list of IP addresses that are trusted to forward traffic to your application. When set, the application will trust the X-Forwarded-For header from these IP addresses to determine the original IP address of the user making the request. This means that if you use the gr.Request object's client.host property, it will correctly get the user's IP address instead of the IP address of the reverse proxy server. Note that only trusted IP addresses (i.e. the IP addresses of your reverse proxy servers) should be added, as any server with these IP addresses can modify the X-Forwarded-For header and spoof the client's IP address."127.0.0.1"export FORWARDED_ALLOW_IPS="127.0.0.1,192.168.1.100"To set environment variables in your terminal, use the export command followed by the variable name and its value. For example:
export GRADIO_SERVER_PORT=8000If you're using a .env file to manage your environment variables, you can add them like this:
GRADIO_SERVER_PORT=8000
GRADIO_SERVER_NAME="localhost"Then, use a tool like dotenv to load these variables when running your application.