【问题标题】:This site can’t provide a secure connection (heroku)此站点无法提供安全连接 (heroku)
【发布时间】:2026-02-05 15:35:01
【问题描述】:

在这里尝试了所有步骤:https://www.ssl2buy.com/wiki/how-to-fix-err-ssl-protocol-error

确切代码: 来自https://techwithtim.net/tutorials/flask/a-basic-website/

from flask import Flask

# Defining the home page of our site
app = Flask(__name__)

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

@app.route("/")  # this sets the route to this page
def home():
    return "Hello! this is the main page <h1>HELLO</h1>"  # some basic inline html@app.route("/")  # this sets the route to this page

【问题讨论】:

    标签: python google-chrome ssl flask server


    【解决方案1】:

    代码的顺序不正确。应在运行应用程序之前定义所有页面/路由 (app.run())。我认为网站上的视频比您链接的网站更能说明问题。

    此外,这个问题与 Heroku 无关,因此我建议将其从标题中删除。

    from flask import Flask
    
    # Defining the home page of our site
    app = Flask(__name__)
    
    @app.route("/")  # this sets the route to this page
    def home():
        return "Hello! this is the main page <h1>HELLO</h1>"
    
    #moved this below @app.route
    if __name__ == "__main__":
        app.run()
    

    【讨论】:

    • 感谢您的评论。尝试如上更改代码,不幸的是仍然遇到相同的错误。
    • 嗯。我不确定是什么可能导致错误。也许提到您在问题中使用的编辑器。这可能有助于其他人回答您的问题。抱歉,我无法提供更多帮助。
    最近更新 更多