Send data to a Panel application

I am developing a Panel application which is fed with data by another software
I did a little proof of concept which uses the tranquilize REST API and which allows to POST data from the other application
However I am not sure this is the best solution.
Does anyone encountered this problem?
Or has a better idea to solve it?

Here is the POC:

  • The panel application served with: panel serve .\rest_api_test.ipynb --show --rest- provider tranquilizer
import param
import panel as pn
import traceback as tb
from tranquilizer import tranquilize

class ExternalDataHandler(param.Parameterized):
    data = param.String(default="")

pn.state.cache["data_handler"] = ExternalDataHandler()

def post_data(data):
        pn.state.cache["data_handler"].data = data
        return f"transaction succeed"
    except Exception as e:
        return ''.join(tb.format_exception(None, e, e.__traceback__))
text = pn.widgets.StaticText(value="")
@pn.depends(data=pn.state.cache["data_handler"], watch=True)
def on_data_received(data):
    text.value = str(data)
app = pn.panel(text)

And the simulation of the other application sending data:

import ast
import requests

url = 'http://localhost:5006/rest/post_data'
data = {'data': 'Test'}

print(ast.literal_eval(, data = data).text))

This is the result:

1 Like

Thanks for the inspiration @xavArtley. I polished it a bit, made a gist and shared on social media


1 Like

Are Swagger docs automatically generated in this way? If yes, where are they?

1 Like

Hi @AntonBiryukovUofC

Take a look at Please provide tranquilizer open api docs at /rest/ endpoint · Issue #3069 · holoviz/panel ( and upvote if you like. Thanks.

1 Like