heartrate
heartrate copied to clipboard
Using heartrate on Google Colaboratory ?
Having read the article https://towardsdatascience.com/3-tools-to-track-and-visualize-the-execution-of-your-python-code-666a153e435e, I was wondering on how to use heartrate on Google Colaboratory? Is this possible and if yes: how exactly to that.
Take a look at https://stackoverflow.com/questions/54465816/how-to-use-flask-in-google-colaboratory-python-notebook. Based on the first answer you could get the IP of the notebook with print(socket.gethostbyname(socket.getfqdn(socket.gethostname())))
and use trace(host='0.0.0.0')
to make heartrate accessible remotely. Does that work?
Take a look at https://stackoverflow.com/questions/54465816/how-to-use-flask-in-google-colaboratory-python-notebook. Based on the first answer you could get the IP of the notebook with
print(socket.gethostbyname(socket.getfqdn(socket.gethostname())))
and usetrace(host='0.0.0.0')
to make heartrate accessible remotely. Does that work?
I have no experience with Flask, so this is a good time to give it a try !
I got the LAST example from https://stackoverflow.com/questions/54465816/how-to-use-flask-in-google-colaboratory-python-notebookworking working in COLAB !
But what exactly should I use as the "server side code AKA: backend" code for the factorial example from your article:
import heartrate from time import sleep
heartrate.trace(browser=True)
def factorial(x): if x == 1: return 1 else: sleep(0.5) return (x * factorial(x-1))
if name == "main": num = 20 print(f"The factorial of {num} is {factorial(num)}")
Use heartrate.trace(host='0.0.0.0')
and port 9999 in the client side.
Use
heartrate.trace(host='0.0.0.0')
and port 9999 in the client side.
This is a COLAB Notebook that works with a demo Flasjk app: https://colab.research.google.com/drive/1ocoD0B0h2F8HhwWz9j9Td4uhvoTk_Um2#scrollTo=lrO47YxeJzTl
How do I convert that, so that it runs the factorial example ?
Welp, I tried, couldn't get anything to work. If I run heartrate on port 80 and then point ngrok to port 80 I get close, but I get a 404. Seems to have to do with the SERVER_NAME config but setting it to something else like the ngrok domain doesn't help.
Welp, I tried, couldn't get anything to work. If I run heartrate on port 80 and then point ngrok to port 80 I get close, but I get a 404. Seems to have to do with the SERVER_NAME config but setting it to something else like the ngrok domain doesn't help.
When I run it on my local PC it seems to work fine, except in my webbrowser I do not see all of the expected output. Especially I am missing the realtime movements of the horizontal bars on teh left. I tried this in Edge, Chrome, Firefox (I could try MS IE of course but I did not do that yet) So what could be cause of this?
I only see this:
Try outside of IPython in just a regular script.
Try outside of IPython in just a regular script.
I will try that!