【问题标题】:My heroku application is not working with flask application我的 heroku 应用程序无法与烧瓶应用程序一起使用
【发布时间】:2021-09-08 23:20:05
【问题描述】:

我的 heroku 应用程序无法运行 我的代码中也没有看到任何错误,这很简单 模板中的 index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title> Srikar's Messaging App!</title>

</head>
</html>

app.py 文件:

from flask import Flask, render_template, url_for, redirect, request, session
from flask_socketio import SocketIO, send
app = Flask(name)


@app.route("/")
def login():
    return render_template('index.html')
@app.route("/home")
def home():
    return "welcome to homepage!"

if name == "main":
    app.run(debug=False,host="0.0.0.0")

需求文件:

Flask==2.0.1
Flask-Login==0.5.0
flask-ngrok==0.0.25
Flask-SQLAlchemy==2.5.1
future==0.18.2
gevent==21.1.2
gevent-websocket==0.10.1
greenlet==1.1.0
gunicorn==20.1.0
python-socketio==5.4.0

我的档案:

web: gunicorn app:app

【问题讨论】:

  • 不是name,是__name__。不过,可能还有无数其他问题,我们需要一些调试信息才能了解这些问题。
  • 哦在堆栈溢出中它没有注册 __ 和 __ ,用于使文本变为粗体
  • 代码其实很简单。

标签: python html flask heroku


【解决方案1】:

在 Heroku 上使用 Flask 时,通常需要绑定到 Heroku 提供的 PORT

p = int(os.environ.get("PORT", 5000))
app.run(debug=False, port=p, host='0.0.0.0')

PS 最好也发布 Heroku 日志,以便有一些关于您遇到的问题的额外信息

【讨论】:

    猜你喜欢
    • 2021-08-17
    • 2015-05-10
    • 2014-11-26
    • 2021-09-02
    • 2014-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多