ina
ina

Reputation: 19534

Google Colab as a REST endpoint

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)

Upvotes: 4

Views: 5038

Answers (1)

Bob Smith
Bob Smith

Reputation: 38589

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.

Upvotes: 2

Related Questions