I am using flask-ngrok to hosting an index.html webpage for my machine learning model. Code to run the webpage:
import flask
from flask import Flask, render_template, request
import pickle
import numpy as np
from flask_ngrok import run_with_ngrok
import warnings
warnings.filterwarnings('ignore')
app = Flask(__name__)
run_with_ngrok(app)
model = pickle.load(open('model_file.p', 'rb'))
@app.route('/', methods=['GET'])
def home():
return render_template('index.html')
@app.route('/', methods=['GET', "POST"])
def predict():
input_values = [float(x) for x in request.form.values()]
inp_features = [input_values]
prediction = model.predict(inp_features)
if prediction > 0.5:
return render_template('index.html', prediction_text='Predicting a Recession in the US in the near future.')
else:
return render_template('index.html', prediction_text='Predicting no Recession in the US in the near future.')
app.run()
**This runs fine, however, when I click on the xxx.ngrok.io link, then it takes me to this warning page: **

Even though I keep hitting on 'Visit Site', it never takes me to the site and just reloads the same warning page. I tried all browsers including edge. I even unblocked 3rd party cookies. Still can't avoid this.
PM from ngrok here. Try using the https url instead of http. We are investigating an issue where the cookie isn’t being set properly on http endpoints.
I ran into a similar issue when serving/testing a Progressive Web App over NGROK. When the app tried to get manifest.webmanifest it would only get the NGROK warning page (which isn't valid JSON), causing an error. I managed to fix it by modifying my link tag in index.html thus:
<link rel="manifest" type="application/json" href="/manifest.webmanifest" />
By specifying type="application/json", the request seems to not trigger the warning message, and I get the result back as application/manifest+json (although sometimes I still get the error, it's not constantly like before). Not using NGROK for prod so this shouldn't be an issue when I move there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With