Python 我的烧瓶应用程序在heroku无法正常工作,你能帮我吗?

Python 我的烧瓶应用程序在heroku无法正常工作,你能帮我吗?,python,flask,heroku,Python,Flask,Heroku,我的flask应用程序在本地主机上运行正常,但在heroku中无法运行。还添加了Procfile。我甚至在Procfile.txt中尝试了web:gunicorn--bind 0.0.0:$PORT-app:app this app.py由以下部分组成 from flask import Flask,request, redirect,render_template,jsonify from werkzeug.utils import secure_filename import xlrd im

我的flask应用程序在本地主机上运行正常,但在heroku中无法运行。还添加了Procfile。我甚至在Procfile.txt中尝试了web:gunicorn--bind 0.0.0:$PORT-app:app this app.py由以下部分组成

from flask import Flask,request, redirect,render_template,jsonify
from werkzeug.utils import secure_filename
import xlrd
import pymongo

import os
from pymongo import MongoClient

app = Flask(__name__)

app.config["IMAGE_UPLOADS"] = "./static"
app.config["ALLOWED_IMAGE_EXTENSIONS"] = ["JPEG", "JPG", "PNG", "GIF","XLSX"]
app.config["MAX_IMAGE_FILESIZE"] = 0.5 * 1024 * 1024
client = MongoClient("mongodb+srv://hemanth:hemanth123@cluster0-pi4b7.mongodb.net/test?retryWrites=true&w=majority")
db = client["creditscore"]
collection = db["creditscore"]

@app.route("/")
def index():
    return render_template("layouts/index1.html")

@app.route("/api")
def api():
    return jsonify({'status':os.getcwd()})

@app.route("/upload", methods=["GET", "POST"])
def upload_image():
    if request.method == "POST":
        if request.files:
            image = request.files["image"]
            filename = secure_filename(image.filename)
            image.save(os.path.join(app.config["IMAGE_UPLOADS"], filename))
            file_location=os.path.join(app.config["IMAGE_UPLOADS"], filename)
            workbook = xlrd.open_workbook(file_location)
            sheet = workbook.sheet_by_index(0)
            psitrnid = int(sheet.cell_value(9,4))
            psiootid  = int(sheet.cell_value(9,5))
            goodtrnid = int(sheet.cell_value(9,7))
            badtrnid = int(sheet.cell_value(9,8))
            goodootid = int(sheet.cell_value(9,10))
            badootid = int(sheet.cell_value(9,11))
            print("Image saved")
            driverIds={
                "driverNames":"Nikhil",
                "psitrnid":psitrnid,
                "psiootid":psiootid,
                "goodtrnid":goodtrnid,
                "badtrnid":badtrnid,
                "goodootid":goodootid,
                "badootid":badootid
                }
            trn_id = { "_id": psitrnid }
            trn_insert = {**trn_id , **driverIds}
            collection.insert_one(trn_insert)
            return jsonify({"status":"Worked",'driverIds':driverIds})
        else:
            print("That file extension is not allowed")
            return jsonify({"status":"file extension not allwed"})
    return render_template("layouts/index1.html")

if __name__ == '__main__':
    app.run(debug=True)
heroku日志显示

2020-05-19T07:49:30.575609+00:00 app[api]: Initial release by user nikhilkumarthota42@gmail.com
2020-05-19T07:49:30.575609+00:00 app[api]: Release v1 created by user nikhilkumarthota42@gmail.com
2020-05-19T07:49:30.684285+00:00 app[api]: Release v2 created by user nikhilkumarthota42@gmail.com
2020-05-19T07:49:30.684285+00:00 app[api]: Enable Logplex by user nikhilkumarthota42@gmail.com
2020-05-19T07:50:10.000000+00:00 app[api]: Build started by user nikhilkumarthota42@gmail.com
2020-05-19T07:50:37.655389+00:00 app[api]: Release v3 created by user nikhilkumarthota42@gmail.com
2020-05-19T07:50:37.655389+00:00 app[api]: Deploy d3a84204 by user nikhilkumarthota42@gmail.com
2020-05-19T07:50:47.000000+00:00 app[api]: Build succeeded
2020-05-19T07:51:14.829022+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=creditscore.herokuapp.com request_id=ac9a892f-958e-4a2e-850d-5b20fa911145 fwd="183.82.137.4" dyno= connect= service= status=503 bytes= protocol=https
2020-05-19T07:51:15.196438+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=creditscore.herokuapp.com request_id=8f756e08-5dd5-4cab-95b6-0fb1340aca41 fwd="183.82.137.4" dyno= connect= service= status=503 bytes= protocol=https

所有安装都已正确完成,我不知道是什么原因导致此错误。请在这方面帮助我,无需在Heroku绑定地址和端口。我还有一个应用程序托管在Heroku,我的Procfile如下所示:

web: gunicorn main:app --log-file -
My
main.py
使用工厂方法创建应用程序:

from myapp import create_app
...
app = create_app()
...

请参考“使用Gunicorn部署Python应用程序”一节。无论如何,它都很有用。

不需要在Heroku绑定地址和端口。我还有一个应用程序托管在Heroku,我的Procfile如下所示:

web: gunicorn main:app --log-file -
My
main.py
使用工厂方法创建应用程序:

from myapp import create_app
...
app = create_app()
...

请参考“使用Gunicorn部署Python应用程序”一节。无论如何,它都很有用。

在此处添加您的
Procfile
。在此处添加您的
Procfile