Set a Template
This guide addresses how to set a template for a deployable app.
There are two ways of building an application using templates; either we explicitly construct the template or we change the global template.
Explicit Constructor
The explicit approach instantiates a template directly and then add components to the template's areas.
Let us construct a very simple app containing two plots in the main
area and two widgets in the sidebar
based on the BootstrapTemplate
class. Let's save this script below into a file called app.py
.
:::{card} app.py
:::
Now we can activate this app on the command line:
Global Template
Another, often simpler approach is to set the global template with the pn.extension()
call. Once the global template is set, we can easily add components to the template using .servable(area=...)
calls. Let's create the same app as above but using this global template approach. We'll save the script below into a file called app_global.py
.
:::{card} app.py
:::
Now, we can activate this app on the command line:
Related Resources
Read Explanation > Templates for explanation.