Google Colab as a REST endpoint

泪湿孤枕 提交于 2019-12-13 04:36:21

问题


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:


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.



来源:https://stackoverflow.com/questions/56031247/google-colab-as-a-rest-endpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!