【问题标题】:How to interact with code cells in a Jupyter notebook via a REST API?如何通过 REST API 与 Jupyter 笔记本中的代码单元进行交互?
【发布时间】:2021-06-13 09:34:43
【问题描述】:

我想做的是制作一个 python 或 R 解释器服务器。

我想让这个服务器能够与我的网络应用程序交互。

例如,编写一些代码块,请求执行这些代码块到解释器服务器并获取执行结果。

似乎Apache Zeppelin 通过rest api 提供了这种功能

Jupyter Notebook 似乎没有提供此类功能。

有没有办法通过 REST API 与 jupyter notebook 中的代码单元交互??

【问题讨论】:

    标签: python jupyter-notebook remote-access apache-zeppelin


    【解决方案1】:

    使用jupyter kernel gateway

    从运行 Jupyter 的机器上的终端执行此操作。

    pip install jupyter_kernel_gateway
    jupyter kernelgateway
    

    然后在笔记本中,用类似的东西检测一个单元格

    # GET /hello/world
    print("hello world")
    

    现在,如果您访问附加了/hello/world 的笔记本的网址(因此它将类似于http://host:port/hello/world),您应该返回hello world

    还有更多,包括对R 的支持。

    当然,细节会有所不同,请阅读手册

    【讨论】:

      猜你喜欢
      • 2020-01-24
      • 2019-06-25
      • 2019-11-13
      • 1970-01-01
      • 2016-07-04
      • 2021-10-12
      • 2017-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多