Skip to content

Commit feaabc5

Browse files
WIP undo this
Signed-off-by: Andy Jakubowski <[email protected]>
1 parent 7f654bc commit feaabc5

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

jupyterlab_deepnote/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ def _load_jupyter_server_extension(server_app):
3131
setup_handlers(server_app.web_app)
3232
name = "jupyterlab_deepnote"
3333
server_app.log.info(f"Registered {name} server extension")
34+
server_app.contents_manager_class = DeepnoteContentsManager

jupyterlab_deepnote/handlers.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,30 @@
22

33
from jupyter_server.base.handlers import APIHandler
44
from jupyter_server.utils import url_path_join
5+
from jupyter_core.utils import ensure_async
56
import tornado
67

8+
79
class RouteHandler(APIHandler):
810
# The following decorator should be present on all verb methods (head, get, post,
911
# patch, put, delete, options) to ensure only authorized user can request the
1012
# Jupyter server
1113
@tornado.web.authenticated
12-
def get(self):
13-
self.finish(json.dumps({
14-
"data": "This is /jupyterlab-deepnote/get-example endpoint!"
15-
}))
14+
async def get(self):
15+
print("🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 YOOOOO")
16+
path = self.get_query_argument("path")
17+
# Use Jupyter Server’s contents_manager, not direct filesystem access.
18+
model = await ensure_async(
19+
self.contents_manager.get(path, type="file", format="text", content=True)
20+
)
21+
result = {"data": model, "path": path}
22+
self.finish(json.dumps(result))
1623

1724

1825
def setup_handlers(web_app):
1926
host_pattern = ".*$"
2027

2128
base_url = web_app.settings["base_url"]
22-
route_pattern = url_path_join(base_url, "jupyterlab-deepnote", "get-example")
29+
route_pattern = url_path_join(base_url, "api", "contents", "resolve")
2330
handlers = [(route_pattern, RouteHandler)]
2431
web_app.add_handlers(host_pattern, handlers)

src/deepnote-content-provider.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ export class DeepnoteContentProvider extends RestContentProvider {
2020
localPath: string,
2121
options?: Contents.IFetchOptions
2222
): Promise<Contents.IModel> {
23+
const isDeepnoteFile = localPath.endsWith('.deepnote');
24+
25+
if (isDeepnoteFile) {
26+
await super.get(`resolve?path=${localPath}`, options);
27+
}
28+
2329
const model = await super.get(localPath, options);
24-
const isDeepnoteFile =
25-
localPath.endsWith('.deepnote') && model.type === 'notebook';
2630

2731
if (!isDeepnoteFile) {
2832
// Not a .deepnote file, return as-is

0 commit comments

Comments
 (0)