Google Colab as a REST endpoint

2019-08-18 10:52发布

Is it possible to send query parameters via POST or GET to a Google Colab notebook? (And also have the response be either plaintext or structured json)

  • How to retrieve the query in Colab?
  • How do you sanitize or suppress the other output so that only plaintext or json is returned to the endpoint call?

1条回答
等我变得足够好
2楼-- · 2019-08-18 11:37

You can make direct HTTP requests to the backend from FE Javascript. Here's an example notebook.

Reproducing the key bits:

A webserver can be started on the kernel to serve up arbitrary resources.

The client needs to reference the resource with https://localhost:{port} but this will automatically be translated to http://localhost:{port}.

By default responses will be cached in the notebook for offline access.

查看更多
登录 后发表回答