Constructor
Parameters
Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable or default to True.
A human-friendly name for the kind of Blocks or Interface being created. Used internally for analytics.
The tab title to display when this is opened in a browser window.
Whether to vertically expand top-level child components to the height of the window. If True, expansion occurs when the scale value of the child components >= 1.
Whether to horizontally expand to fill container fully. If False, centers and constrains app to a maximum width. Only applies if this is the outermost Blocks in your Gradio app.
A tuple corresponding [frequency, age] both expressed in number of seconds. Every frequency seconds, the temporary files created by this Blocks instance will be deleted if more than age seconds have passed since the file was created.
Class Methods
from_config
A dictionary containing the configuration of the Blocks.
A list of functions that are used in the Blocks. Must be in the same order as the dependencies in the config.
An external url to use as a root URL when serving files for components in the Blocks.
A Blocks instance.
get_instances
List of all current instances.
Instance Methods
queue
Enables queueing for the Blocks app, allowing for better handling of concurrent requests.launch
Launches the Blocks app locally or on a public URL.integrate
Integrates the Blocks app with various platforms.load
Sets up an event that runs when the Blocks app is first loaded.unload
Sets up an event that runs when the user closes the Blocks app.Example
Notes
Compared to the Interface class, Blocks offers more flexibility and control over:- The layout of components
- The events that trigger the execution of functions
- Data flows (e.g. inputs can trigger outputs, which can trigger the next level of outputs)