I am trying to build a website using Flask, in a Google Colab Python notebook. However, running a regular Flask code that works on a regular Python, fails to work on Google
The server code:
import socket
print(socket.gethostbyname(socket.getfqdn(socket.gethostname())))
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
import threading
threading.Thread(target=app.run, kwargs={'host':'0.0.0.0','port':80}).start()
Client code:
import requests
r = requests.get("http://172.28.0.2/")
print(r.status_code)
print(r.encoding)
print(r.apparent_encoding)
print(r.text)
To restart Flask you may click menu: runtime->restart runtime
Share link here :