I have this python code to deploy to Heroku:
import flask
import pandas as pd
def create_app():
app = flask.Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
"""
Index page view handler.
:return: rendered index.html template
"""
return flask.render_template('index.html')
@app.route('/data', methods=['GET', 'POST'])
def data():
"""
Data view handler
:return: JSON object of the data CSV file
"""
data = pd.read_csv('task_data.csv')
context = {
'sensor_data': data.to_dict(orient='list')
}
return flask.jsonify(context)
return app
if __name__ == "__main__":
app = create_app()
app.config['TEMPLATES_AUTO_RELOAD'] = True
# serve the application on port 7410
app.run(host='0.0.0.0', port=7410)
Procfile
web: python main.py
After I uploaded the files I get now this errors in log view:
2020-02-26T14:08:32.485820+00:00 heroku[web.1]: State changed from crashed to starting
2020-02-26T14:08:38.283732+00:00 heroku[web.1]: Starting process with command
python main.py
2020-02-26T14:08:41.705572+00:00 app[web.1]: * Serving Flask app "main" (lazy loading)
2020-02-26T14:08:41.705637+00:00 app[web.1]: * Environment: production
2020-02-26T14:08:41.705644+00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2020-02-26T14:08:41.705705+00:00 app[web.1]: Use a production WSGI server instead.
2020-02-26T14:08:41.705763+00:00 app[web.1]: * Debug mode: off
2020-02-26T14:08:41.722252+00:00 app[web.1]: * Running on http://0.0.0.0:7410/ (Press CTRL+C to quit)
2020-02-26T14:09:38.524175+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-26T14:09:38.453425+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-02-26T14:09:38.453485+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-02-26T14:09:38.509347+00:00 heroku[web.1]: Process exited with status 137
Please advise how to fix this error ?