awesome-panel / panel-chemistry

๐Ÿงช๐Ÿ“ˆ ๐Ÿ. The purpose of the panel-chemistry project is to make it really easy for you to do DATA ANALYSIS and build powerful DATA AND VIZ APPLICATIONS within the domain of Chemistry using using Python and HoloViz Panel.
MIT License
119 stars 16 forks source link

Question about static-dirs in panel #26

Closed cschlick closed 2 years ago

cschlick commented 2 years ago

Hi, I've been working with the pdbe molstar code and I think it's fantastic. I'm a little confused about how static files would work for panel in a jupyter notebook though. Is there a way to specify an assets directory in a notebook without running panel serve --static-dirs from the command line?

MarcSkovMadsen commented 2 years ago

@Jhsmit . Do you know this?

Jhsmit commented 2 years ago

Yes, you can also use Jupyter directly, without the need for panel static dirs

For example like this, when you start jupyter notebook in the panel-chemistry root directory

PDBeMolStar(
    name='Local File',
    sizing_mode='stretch_width',
    height=500,
    custom_data = {
        'url': 'http://localhost:8888/files/examples/assets/1qyn.pdb',
        'format': 'pdb'
    },
)

I've made a PR for add docs but looks like there is a problem with the tests at the moment

MarcSkovMadsen commented 2 years ago

How come http://localhost:8888/files/... works @Jhsmit? (I did not know that :-)).

Jhsmit commented 2 years ago

Since you can 'download' all your files and subdirectories from where you run jupyter notebook, I guess some part of jupyter serves all your files on an http server or something like that. Which is of course usually used for downloading your files if you run jupyter remotely, but if you run things locally you can use it to serve your files to PDBeMolStar directly.

It should also be possible to serve local files through something like python's SimpleHTTPServer, but I havent tested this.

cschlick commented 2 years ago

Thanks so much guys. I also didn't know about the /files/ aspect to Jupyter, but that works really well for me.