Closed Roger-luo closed 4 years ago
Good idea! This would also be useful when hosting pluto notebooks online - sneak peek
I find maybe both create
and open
notebooks would be more useful, if these APIs are exported.
@fonsp I'm wondering if there are some internal function I could use in Julia to open a notebook directly (e.g how the web frontend create and open a notebook?) I guess I could look from there.
Hi! The internal functions are there, but it's not a one-liner yet.
This is the code that opens a notebook from a path: https://github.com/fonsp/Pluto.jl/blob/master/src/webserver/Static.jl#L69-L75
Check out the master version of Pluto, and:
import Pluto
s = Pluto.ServerSession()
Pluto.SessionActions.open(s, "~/hello.jl");
Pluto.run(; session=s)
Sorry if this is premature (am on julia 1.6), but just FYI this doesn't work for me. The Pluto.SessionActions.open(s, "~/hello.jl")
just generates a screen dump of all text in the notebook. Then Pluto.run(;session=s)
just opens as usual, i.e. it doesn't open a specific notebook.
julia> versioninfo()
Julia Version 1.6.0-DEV.771
Commit 0336f672db (2020-08-30 01:07 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4
(@v1.6) pkg> st Pluto
Status `~/.julia/environments/v1.6/Project.toml`
[c3e4b0f8] Pluto v0.11.10 `https://github.com/fonsp/Pluto.jl.git#master`
All of this is intended behavior - the main point was that if you go to localhost:1234
after this code, you'll see that the notebook is already running.
If you want the direct link:
"http://localhost:1234/edit?id=$(notebook.notebook_id)"
ah! that's what I want, thank you!
It would be convenient if Pluto could support an argument in
run
to open a local notebook directly.