【问题标题】:localhost sent an invalid response flasklocalhost 发送了一个无效的响应烧瓶
【发布时间】:2022-01-04 09:13:02
【问题描述】:

这是我的 main.py

from flask import Flask, render_template
from oauth import Oauth

app = Flask(__name__, template_folder='template')

@app.route("/")
def home():
  return render_template("index.html",discord_url=Oauth.discord_login_url)

@app.route("/login")
def login():
    return "Success"

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

我的 index.html

<html>
  <head>
     <title>Home Page</title>
  </head>
  <body>
    <h1>Welcome to Hexon X dashboard!</h1>
    Click here to login:
    <a href="{{discord_url}}"><button>Login with discord</button></a>
  </body>
</html>

我的 oauth.py


class Oauth:
    client_id = "Secret"
    client_secret = "Secret "
    redirect_uri = "https://127.0.0.1:5000/login"
    scope = "identify%20email%20guilds"
    discord_login_url = "secret too"
    discord_token_url = "https://discord.com/api/oauth2/token"
    discord_api_url = "https://discord.com/api"

给我这个错误

127.0.0.1 sent an invalid response

有人可以帮我吗 返回网址无效 并且重定向后不返回成功

【问题讨论】:

    标签: python html flask localhost host


    【解决方案1】:

    如果我是对的,我在这里看到的唯一问题是redirect_uri = "https://127.0.0.1:5000/login"。 localhost 只适用于http 而不是https(虽然我们可以让它在 https 中工作,但在大多数情况下,我们不需要这样做)。所以尝试改变它,看看它是否有效。

    【讨论】:

      猜你喜欢
      • 2018-11-13
      • 2021-07-22
      • 2017-12-04
      • 2014-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多