Allow to easily register custom request handlers
My use case is that I was trying to see how I'd allow users to download very large non-static files (e.g. streamed from elsewhere) to users of my app. I thought that maybe I could just build links that'd expose these files to download, these links pointing to another endpoint of my app that when hit would start the download. Something along those lines.
Panel allows to set up one of two REST provides: param and tranquilizer (with e.g. --rest-provider param). Users can register other REST providers via the panel.io.rest entry point (I've actually not tried that). However, and if I understand correctly, this means that you need to build a package.
I'm wondering whether it wouldn't be easier to allow users to register custom request handlers in their setup script (--setup mysetup.py). Maybe exposing a global CUSTOM_PATTERNS list that users could import and extend as they like.
Should be trivial to implement, we already support this via the extra_patterns argument in pn.serve and the same could be achieved by extracting some fixed variable from the --setup script.
Ah indeed I missed extra_patterns in get_server, might be worth documenting that better.
the same could be achieved by extracting some fixed variable from the --setup script.
You mean that users would have to define some specific variable like extra_patterns = [...] and we'd look for them after executing the module? Not sure I like that so much, linters won't for sure :D What's against extending a global list?
I would like to add a custom tornado handler too. I would be running panel serve pages/*.py .... How would I add a custom tornado handler using this setup?