尝试在 heroku 上部署 react-flask 应用程序时崩溃应用程序错误

时间:2021-05-17 10:11:16

标签: python reactjs flask heroku

我目前在运行 heroku logs --tail 命令时收到此错误。

at=error code=H10 desc="App crashed" method=GET path="/" host=digital-engagement-tool.herokuapp.com request_id=72b795df-278b-41f8-885c-71cad4b302f0 fwd="123.201. 36.104" dyno=connect=service=status=503 bytes=protocol=https

2021-05-18T07:51:47.875518+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=digital-engagement- tool.herokuapp.com request_id=ddd95750-0437-41b2-89e8-973c709039f0 fwd="123.201.36.104" dyno= connect= service= status=503 bytes= protocol=https

我的档案:

web: gunicorn app:react-flask-app

我将应用程序命名为“react-flask-app”,因为这是我的 package.json 文件中的名称。对吗?

我的 api.py 文件:

app = Flask(__name__, static_folder='./build', static_url_path='/')
app = Flask(__name__, static_folder='./build', static_url_path='/')
app.config['SQLALCHEMY_DATABASE_URI'] = Config.SQLALCHEMY_DATABASE_URI
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['MAIL_SERVER']= Config.MAIL_SERVER
app.config['MAIL_PORT'] = Config.MAIL_PORT
app.config['MAIL_USERNAME'] = Config.MAIL_USERNAME
app.config['MAIL_PASSWORD'] = Config.MAIL_PASSWORD
app.config['MAIL_USE_SSL'] = Config.MAIL_USE_SSL
mail = Mail(app)
db = flask_sqlalchemy.SQLAlchemy(app)


@app.route('/')
def index():
  return app.send_static_file('index.html')

----与我的申请相关的其他路线。示例:

 @app.route('/hcp-npi-name', methods=['GET', 'POST'])
 def hcp_npi_name():
   engine = connect_pg()
   param = request.get_json()
   sql = "select a.* from dim_hcp_details a join dim_geography_table b on a.aligned_geography_id = 
      b.geography_id where b.user_id = " + str(param['user_id']) + " limit 1"
   print(sql)
   hcp_details = pd.read_sql_query(sql,engine)
   hcp_details['npi_hcp_concat'] = "[" + hcp_details['npi'] + "]" + hcp_details['first_name']
   hcp_dict = hcp_details.to_dict()
   return jsonify(hcp_dict)

然后:

@app.errorhandler(404)
def not_found(e):
   return app.send_static_file('index.html')

if __name__ == "__main__":
  app.run(host='0.0.0.0', debug=False, port=os.environ.get('PORT', 80))

此后,我还在终端中运行这些命令来创建 heroku 应用程序。

 heroku create digital-engagement-tool
 heroku git:remote -a digital-engagement-tool

在那之后,我使用 git push heroku master 命令推送了这个。

我已使用此链接在 heroku 上进行部署:How to Deploy a React + Python Flask Project on Heroku

有人知道我哪里出错了吗?

0 个答案:

没有答案