Can Bokeh facilitate a simple web-based text editor?

Is it possible to open a simple text editor for, say, a simple config file?

this would only make sense for server instances with bokeh --serve, like for a dashboard.

Say I’ve got a small text file, named myAppSettings.cfg:

[section1]
N=3
msg='hello'

Say the user wants to change N to 4, using the web interface.

How can this file be opened in a simple web-based editor then save the file in the same location where it’s being served?

Perhaps using Bokeh’s Tornado web server?

I would say “probably possible in principle” but I have zero experience using or integrating any front-end editors, so I unfortunately can’t offer any concrete advice or speculate about how difficult it might be.

then save the file in the same location where it’s being served?

AFAIK he only place that something cold be saved to disk at an arbitrary location is the system that the Bokeh server is running on. If you mean the system where the browser is, that’s impossible, due to browser security limitations.

Hello @Bryan,

Thanks. It sounds like this has not been requested before and may not be a high priority.

I know people use Bokeh for dashboards, and config files are not unusual.

Are there other approaches I’m missing?

How do Bokeh-based dashboards change config files for the underlying backend application?

An online simple text editor like any of these would sure be helpful:

Accessing the file on the same server where bokeh --serve is running would be great.

It’s definitely never been requested before.

How do Bokeh-based dashboards change config files for the underlying backend application?

I’ve never heard of anyone wanting to do this, so I can’t say for sure. But if they did, I might speculate they would use the basic TextAreaInput widget.

Accessing the file on the same server where bokeh --serve is running would be great.

How is this supposed to work when there are multiple Bokeh server instances e.g. running behind a load balancer? Bokeh won’t have an opinion, but I think you would have to have a central configuration service or database that you update. FWIW accepting arbitrary user input and writing it to files also seems like a somewhat risky proposition to me.

In any event, at this point a GitHub Issue to requests a new feature would be the next reasonable step.

Well, this all makes plenty of sense, including the security concerns.

I only run 1 or 2 bokeh instances at a time, from the command line, so clearly there’s more to consider when integrating another application into Bokeh.

The simplest approach is probably to run a web-based text editor entirely separately from Bokeh and allow the interface to be at the config file level.

As long the Bokeh dashboard can re-open or re-evaluate the updated file that will serve the same purpose.

Thanks. I don’t plan to open a feature request.

Although a reply is already marked as a solution, if I can add another one:
Panel, which is based on Bokeh so you’ll get quickly up & running with your experience, has an Ace widget:
https://panel.holoviz.org/reference/widgets/Ace.html#widgets-gallery-ace

It can use a “.ini” file as filename to have the right rendering.

If you need help making the callback attached to the .value parameter to update your ini file just ask away.

As Bryan said, it’s only on server side. On client side, there is a FileDownload button available… Synchronization won’t be possible though.

1 Like