Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,30 @@ def change(self, fn: Callable, inputs: List[Component], outputs: List[Component]


class Blocks(Launchable, BlockContext):
def __init__(self, theme="default"):
def __init__(
self,
theme: str = "default",
analytics_enabled: Optional[bool] = None,
mode: str = "blocks",
):

# Cleanup shared parameters with Interface
self.save_to = None
self.ip_address = utils.get_local_ip_address()
self.api_mode = False
self.analytics_enabled = True
self.theme = theme
self.requires_permissions = False # TODO: needs to be implemented
self.enable_queue = False
self.is_space = True if os.getenv("SYSTEM") == "spaces" else False
self.mode = mode

# For analytics_enabled and allow_flagging: (1) first check for
# parameter, (2) check for env variable, (3) default to True/"manual"
self.analytics_enabled = (
analytics_enabled
if analytics_enabled is not None
else os.getenv("GRADIO_ANALYTICS_ENABLED", "True") == "True"
)

super().__init__()
self.blocks = {}
Expand Down
3 changes: 1 addition & 2 deletions gradio/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __init__(
server_name (str): DEPRECATED. Name of the server to use for serving the interface - pass in launch() instead.
server_port (int): DEPRECATED. Port of the server to use for serving the interface - pass in launch() instead.
"""
super().__init__()
super().__init__(analytics_enabled=analytics_enabled, mode="interface")

if not isinstance(fn, list):
fn = [fn]
Expand Down Expand Up @@ -394,7 +394,6 @@ def clean_html(raw_html):
self.share = None
self.share_url = None
self.local_url = None
self.ip_address = utils.get_local_ip_address()

if show_tips is not None:
warnings.warn(
Expand Down
7 changes: 4 additions & 3 deletions gradio/launchable.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,14 @@ def launch(
"is_google_colab": is_colab,
"is_sharing_on": share,
"share_url": share_url,
"ip_address": self.ip_address,
"ip_address": self.ip_address if hasattr(self, "ip_address") else "",
"enable_queue": self.enable_queue,
"show_tips": self.show_tips,
"api_mode": self.api_mode,
"api_mode": self.api_mode if hasattr(self, "api_mode") else "",
"server_name": server_name,
"server_port": server_port,
"is_spaces": self.is_space,
"is_spaces": self.is_space if hasattr(self, "is_space") else "",
"mode": self.mode if hasattr(self, "mode") else "",
}
if self.analytics_enabled:
utils.launch_analytics(data)
Expand Down
4 changes: 2 additions & 2 deletions gradio/templates/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
<title>Gradio</title>
<script type="module" crossorigin src="./assets/index.54d43414.js"></script>
<link rel="stylesheet" href="./assets/index.e209fdc1.css">
<script type="module" crossorigin src="./assets/index.43c561e9.js"></script>
<link rel="stylesheet" href="./assets/index.4f55c05a.css">
</head>

<body style="height: 100%; margin: 0; padding: 0">
Expand Down