0

I keep getting an H10 error, i tried to change my procfile but it didn't help. it works locally on my computer but the Heroku app doesn't open. would like to get help! the error:

at=error code=H10 desc="App crashed" method=GET path="/" 

code: app file :

import flask
from flask import request, make_response, jsonify
from flask_mongoengine import  MongoEngine
from mongoengine import Document,IntField, StringField

app = flask.Flask(__name__)
database_name="API"
password=""
DB_URI=""
app.config['MONGODB_HOST']=DB_URI
db=MongoEngine()
db.init_app(app)

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

class Book(Document):
    book_id=IntField(required=True)
    name=StringField()
    author=StringField()

    def to_json(self):
        return {
            "book_id":self.book_id,
            "name":self.name,
            "author":self.author
        }

@app.route('/api/db_populate',methods=['POST'])
def db_populate():
    book1=Book(book_id=1,name="A game",author="jim")
    book2=Book(book_id=2,name="lord of the rings",author="jon")
    book1.save()
    book2.save()
    return make_response("",201)

@app.route('/api/books', methods=['GET'])
def api_books():
    books=[]
    for book in Book.objects:
        books.append(book)
    return make_response(jsonify(books),200)

@app.route('/', methods=['GET'])
def home():
    return jsonify("hello")

procfile :

web: gunicorn app:app

i have requirements and runtime files too. thank you for any help.

1 Answers1

0

my requirements file looks like this before:

flask
pandas
gunicorn

I went over the log tail of Heroku again and notice that many lines after the H10 error appeared, the line:"ModuleNotFoundError: No module named 'flask_mongoengine'" appears. so I changed my req file to this:

flask
pandas
gunicorn
flask_mongoengine

and it worked!