Run Flask server on Gradient Notebook

Hello everyone,

While speaking with the gradient Team, I’ve been told that it is possible to use the Tensorboard port to run a Flask server instead. I’m preparing an ML course for students and want them to quickly setup a Test API on a GPU model to test things.

Here is the code that I run, which works in the cell.

from flask import Flask
import threading

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

threading.Thread(target=app.run, kwargs={'host':'0.0.0.0','port':6006}).start()

It’s not clear to me what is the NOTEBOOK id and CLUSTER id for the public URL.
https://tensorboard.NOTEBOOK.CLUSTER.paperspacegradient.com
I tried all combinations unsuccessfully.

Here is the URL of my notebook:

https://console.paperspace.com/tegxjobi5/notebook/rkkr56dfsi967qw?file=Test%20server.ipynb

Thank you for your help

Hi @kikohs

The notebook ID can be found on the notebook list view or from the notebook page in the URL. The ID is after /notebook/.... The notebook ID in this case is rkkr56dfsi967qw.

The default notebook cluster ID is clw6rxq2s. (If using a private cluster, you can grab the ID from the clusters page.)

The URL would be:

https://tensorboard.rkkr56dfsi967qw.clw6rxq2s.paperspacegradient.com

Hi Daniel,
Thank you for your response.
I’m not sure why but I have a 404 not found and a certificate error. The certificate I could understand but the URL doesn’t seem right.
I recreated another notebook from scratch to be sure.

Here it is: https://console.paperspace.com/tegxjobi5/notebook/rv9k5l740yuw46t?file=flask.ipynb

Thanks.

Hi @kikohs,

Sorry about that - we were mistaken. The ID is not rkkr56dfsi967qw, which is your Repo ID, which doesn’t change. It’s sort of like a project ID. You would need the notebook ID of the current running notebook. You would find it here:

The rest is correct. Let us know how you get on.

Best,

No luck…

Anyways the HTTPS is an issue for sure if you want to use it from a client-side thing.
Thanks