Skip to content

Commit ff341a1

Browse files
committed
update readme
1 parent 1b58d29 commit ff341a1

File tree

1 file changed

+40
-24
lines changed

1 file changed

+40
-24
lines changed

examples/simple/README.md

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
11
# Jupyter Server Simple Extension Example
22

3-
This folder contains an example of 2 simple extensions on top of Jupyter Server.
3+
This folder contains example of simple extensions on top of Jupyter Server and review configuration aspects.
44

55
## Install
66

77
You need `python3` to build and run the server extensions.
88

99
```bash
10-
conda create -y -n jupyter_server_example python=3.7 && \
10+
git clone https://github.com/jupyter/jupyter_server && \
11+
cd examples/simple && \
12+
conda create -y -n jupyter_server_example python=3.7 && \
1113
conda activate jupyter_server_example && \
1214
pip install -e .
1315
```
1416

1517
**OPTIONAL** If you want to build the Typescript code, you need `npm` on your local env. Compiled javascript is provided as artifact in this repository, so this Typescript build step is optional. The Typescript source and configuration has been taken from https://github.com/markellekelly/jupyter-server-example.
1618

1719
```bash
18-
npm install
19-
npm run build
20+
npm install && \
21+
npm run build
2022
```
2123

22-
## Start Extension 1 and Extension 2
24+
## Start Extension 1
2325

2426
```bash
25-
# Start the jupyter server, it will load both simple_ext1 and simple_ext2 based on the provided trait.
26-
jupyter server --ServerApp.jpserver_extensions="{'simple_ext1': True, 'simple_ext2': True}"
27-
```
28-
29-
Optionally, you can copy `simple_ext1.json` and `simple_ext2.json` configuration to your env `etc` folder and start only Extension 1, which will also start Extension 2.
30-
31-
```bash
32-
pip uninstall -y jupyter_simple_ext
33-
python setup.py install
34-
cp -r ./etc $(dirname $(which jupyter))/..
35-
# Start the jupyter server extension simple_ext1, it will also load simple_ext2 because of load_other_extensions = True..
36-
# When you invoke with the entrypoint, the default url will be opened in your browser.
37-
jupyter simple-ext1
27+
# Start the jupyter server activating simple_ext1 extension.
28+
jupyter server --ServerApp.jpserver_extensions="{'simple_ext1': True}"
3829
```
3930

4031
Now you can render `Extension 1` Server content in your browser.
@@ -61,6 +52,15 @@ open http://localhost:8888/simple_ext1/redirect
6152
open http://localhost:8888/static/simple_ext1/favicon.ico
6253
```
6354

55+
## Start Extension 2
56+
57+
The following command starts both `simple_ext1` and `simple_ext2` extensions.
58+
59+
```bash
60+
# Start the jupyter server, it will load both simple_ext1 and simple_ext2 based on the provided trait.
61+
jupyter server --ServerApp.jpserver_extensions="{'simple_ext1': True, 'simple_ext2': True}"
62+
```
63+
6464
You can also render `Extension 2` Server content in your browser.
6565

6666
```bash
@@ -70,12 +70,29 @@ open http://localhost:8888/static/simple_ext2/test.html
7070
open http://localhost:8888/simple_ext2/params/test?var1=foo
7171
```
7272

73-
## Settings
73+
## Start with Entrypoints
74+
75+
Optionally, you can copy `simple_ext1.json` and `simple_ext2.json` configuration to your env `etc` folder and start only Extension 1, which will also start Extension 2.
76+
77+
```bash
78+
pip uninstall -y jupyter_simple_ext && \
79+
python setup.py install && \
80+
cp -r ./etc $(dirname $(which jupyter))/..
81+
# Start the jupyter server extension simple_ext1, it will also load simple_ext2 because of load_other_extensions = True..
82+
# When you invoke with the entrypoint, the default url will be opened in your browser.
83+
jupyter simple-ext1
84+
```
85+
86+
## Configuration
87+
88+
Stop any running server (with `CTRL+C`) and start with additional configuration on the command line.
7489

75-
Stop any running server (with CTRL+C) and start with additional settings on the command line.
90+
The provided settings via CLI will override the configuration that reside in the files (`jupyter_simple_ext1_config.py`...)
7691

7792
```bash
78-
jupyter server --ServerApp.jpserver_extensions="{'simple_ext1': True, 'simple_ext2': True}" --SimpleApp1.cli=OK
93+
jupyter server \
94+
--ServerApp.jpserver_extensions="{'simple_ext1': True, 'simple_ext2': True}" \
95+
--SimpleApp1.cli=OK
7996
```
8097

8198
Check the log, it should return on startup something like the following base on the trait you have defined in the CLI and in the `jupyter_server_config.py`.
@@ -84,7 +101,6 @@ Check the log, it should return on startup something like the following base on
84101
[SimpleApp1] SimpleApp1.app OK
85102
[SimpleApp1] SimpleApp1.file OK
86103
[SimpleApp1] SimpleApp1.cli OK
87-
[SimpleApp1] Complete Settings {'simple_ext1_config': {}, 'simple_ext1_template_paths': ['/home/datalayer/repos/jupyter-server/examples/simple/simple_ext1/templates'], 'simple_ext1_jinja2_env': <jinja2.environment.Environment object at 0x105ed7438>, 'log_function': <function log_request at 0x105e2d950>, 'base_url': '/', 'default_url': '/', 'template_path': ...
88104
```
89105

90106
## Start only Extension 2
@@ -137,7 +153,7 @@ The generated configuration should contains the following.
137153
...
138154
```
139155

140-
The `hello`, `ignoare_js` and `simple11_dir` are traits defined on the SimpleApp11 class.
156+
The `hello`, `ignore_js` and `simple11_dir` are traits defined on the SimpleApp11 class.
141157

142158
It also implements additional flags and aliases for these traits.
143159

@@ -152,7 +168,7 @@ jupyter simple-ext11 --hello --simple11-dir any_folder
152168
jupyter server --ServerApp.jpserver_extensions="{'simple_ext11': True}" --hello --simple11-dir any_folder
153169
```
154170

155-
Ensure the following URLs give respond correctly.
171+
Ensure the following URLs respond correctly.
156172

157173
```bash
158174
# Jupyter Server Home Page.

0 commit comments

Comments
 (0)