Build Hello World App
Welcome to the "Build Hello World App" tutorial! Get ready to dive into the world of Panel and serve your very first app.
Serve the App
Let's get started by serving our simple Hello World app using Panel. Choose a tab below to continue:
:::::{tab-set}
::::{tab-item} Script :sync: script
In this section, we'll create the simplest Panel .py
app:
:::{note} Here's a breakdown of the code:
panel
: The Panel python package, conventionally imported aspn
.pn.extension()
: Loads javascript dependencies and configures Panel.pn.panel(...)
: Creates a displayable Panel component..servable()
: Displays the component in a server app. :::
Copy the code into a file named app.py
and save it. Then, run the Panel server in your terminal with:
::::
::::{tab-item} Notebook :sync: notebook
In this section, we'll create the simplest Panel Notebook app:
:::{note} Here's what the code does:
panel
: The Panel python package, conventionally imported aspn
.pn.extension()
: Loads thepyviz_comms
notebook extension, loads javascript dependencies and configures Panel.pn.panel(...)
: Creates a displayable Panel component, which can be directly displayed in the notebook..servable()
: Displays the component in a server app. :::
Copy the above code cells into a clean notebook named app.ipynb
. Run the cells and save the notebook as app.ipynb
.
Then, run the Panel server in your terminal with:
:::::
Upon successful startup, you'll see the server's URL in the terminal.
Open your browser at that URL to view the app. It should look like
.
Play around with the app by modifying the "Hello World"
text, saving the file and observe how it updates in real-time. To stop the server, simply press CTRL+C
in the terminal.
Recap
Congratulations on serving your first Panel app! Let's recap what we've learned:
How to serve a Python script or Notebook using
panel serve app.py
orpanel serve app.ipynb
, respectively.How to enable auto reload with the
--dev
flag.How to stop the Panel server with
CTRL+C
.
Resources
Tutorials
How-to
Keep exploring and building with Panel! 🚀