首页 > 解决方案 > Flask 在 Colab 上发送双重 GET 信号

问题描述

当我只按一次时,我的简单烧瓶程序正在发送双重 GET 请求?

我在这里看到了类似的帖子,上面说这可能是浏览器/扩展程序问题,但我检查了我的扩展程序,实际上只有谷歌扩展程序。

我该如何解决这个问题?我真的不能在谷歌本身上运行我的程序吗?

import os
from flask import send_from_directory, Flask, render_template_string
from flask_ngrok import run_with_ngrok

app = Flask(__name__)
run_with_ngrok(app)  

@app.route("/")
def hello():
  content='Hello!'
  return render_template_string(f'''<!doctype html>
  <html>
      <head>
          <link rel="icon" href="data:,">
      </head>
      <body>
          <h1>{content}</h1>
      </body>
  </html>
  ''')

if __name__ == "__main__":
    app.run()

* Serving Flask app "__main__" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Running on http://af8a7bff0c58.ngrok.io
 * Traffic stats available on http://127.0.0.1:4040
127.0.0.1 - - [12/May/2021 07:59:22] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [12/May/2021 07:59:23] "GET / HTTP/1.1" 200 -


标签: pythongoogle-chromeflask

解决方案


推荐阅读