卡在“您即将访问:xxx.ngrok.io”并且无法访问我的 ngrok.io 网页

问题描述 投票:0回答:2

我正在使用flask-ngrok 为我的机器学习模型托管index.html 网页。运行网页的代码:

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()

**这运行正常,但是,当我单击 xxx.ngrok.io 链接时,它会将我带到此警告页面:**

即使我一直点击“访问网站”,它也不会带我进入该网站,而只是重新加载相同的警告页面。我尝试了所有浏览器,包括 Edge。我什至解锁了第 3 方 cookie。还是无法避免这一点。

python flask ngrok
2个回答
0
投票

来自ngrok的PM在这里。尝试使用 https url 而不是 http。我们正在调查未在 http 端点上正确设置 cookie 的问题。


0
投票

我在通过 NGROK 提供/测试渐进式 Web 应用程序时遇到了类似的问题。当应用程序尝试获取

manifest.webmanifest
时,它只会获取 NGROK 警告页面(不是有效的 JSON),从而导致错误。我设法通过修改
link
中的
index.html
标签来修复它:

<link rel="manifest" type="application/json" href="/manifest.webmanifest" />

通过指定

type="application/json"
,请求似乎不会触发警告消息,并且我得到的结果为
application/manifest+json
(尽管有时我仍然会收到错误,但并不像以前那样持续)。不使用 NGROK 作为产品,所以当我搬到那里时这不应该成为问题。

© www.soinside.com 2019 - 2024. All rights reserved.