Is there a general way to run Web Applications on Google Colab?

前端 未结 4 1755
小蘑菇
小蘑菇 2020-12-29 13:06

I would like to develop web apps in Google colab. The only issue is that you need a browser connected to local host to view the web app, but Google colab doesn\'t have a bro

4条回答
  •  时光取名叫无心
    2020-12-29 13:32

    Answer is found here

    Launch a Dash app in a Google Colab Notebook

    ### Install ngrok
    !wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
    !unzip ngrok-stable-linux-amd64.zip
    
    ### Run ngrok to tunnel Dash app port 8050 to the outside world. 
    ### This command runs in the background.
    get_ipython().system_raw('./ngrok http 8050 &')
    
    ### Get the public URL where you can access the Dash app. Copy this URL.
    ! curl -s http://localhost:4040/api/tunnels | python3 -c \
        "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"
    

    Then launch your webapp on port 8050

提交回复
热议问题