I am trying to host a Flask web application on Heroku, while I use these steps to get my web application hosted:
{git init
git add .
git commit -m "Initial commmit"
heroku create bukkit-list
git remote -v
git push heroku master}
After I do all of this, I get absolutely no error in my terminal, but the flask application is still not working. The logs for Heroku are given below.
2022-02-12T09:27:20.056100+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=bukkit-list.herokuapp.com request_id=cd77d2eb-110d-4943-bae1-18601c9f90b7 fwd="103.79.250.41" dyno= connect= service= status=503 bytes= protocol=https
2022-02-12T09:27:20.601039+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=bukkit-list.herokuapp.com request_id=5fe216d1-0f09-4777-8c6f-bee6b4b53f74 fwd="103.79.250.41" dyno= connect= service= status=503 bytes= protocol=https
2022-02-12T09:27:29.589547+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=bukkit-list.herokuapp.com request_id=169389de-b2ed-43a3-ae8e-1203558e9c86 fwd="103.79.250.41" dyno= connect= service= status=503 bytes= protocol=https
2022-02-12T09:27:47.095193+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=bukkit-list.herokuapp.com request_id=316fd6b2-9ffc-40ea-bee5-f0b3630a2948 fwd="103.79.250.41" dyno= connect= service= status=503 bytes= protocol=https
2022-02-12T09:27:48.317531+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=bukkit-list.herokuapp.com request_id=6416476f-2e45-4dd2-a2f9-85fdcccb5883 fwd="103.79.250.41" dyno= connect= service= status=503 bytes= protocol=https
2022-02-12T09:28:17.730376+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=bukkit-list.herokuapp.com request_id=3a7058d4-9796-4a62-8ec5-4be44728f638 fwd="103.79.250.41" dyno= connect= service= status=503 bytes= protocol=https
2022-02-12T09:28:18.395460+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=bukkit-list.herokuapp.com request_id=57d66c4d-8fe9-4801-8d9d-a65d9986b808 fwd="103.79.250.41" dyno= connect= service= status=503 bytes= protocol=https
My app.py code
from flask import Flask, redirect, render_template, request
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///tasks.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class Task(db.Model):
sno = db.Column(db.Integer, primary_key = True)
title = db.Column(db.String(200), nullable=False)
desc = db.Column(db.String(500), nullable=False)
def __repr__(self) -> str:
return f'{self.title} - {self.sno}'
# Routes
@app.route('/')
def home():
return render_template('home.html')
# Task list area ==========================================
@app.route('/taskList')
def taskList():
taskList = Task.query.all()
return render_template('taskList.html', taskList=taskList)
@app.route('/delete/<int:sno>')
def delete(sno):
task = Task.query.filter_by(sno=sno).first()
db.session.delete(task)
db.session.commit()
return redirect('/taskList')
@app.route('/addTask')
def addTask():
return redirect('/TaskEditor_Add')
# Add task area =============================================
@app.route('/TaskEditor_Add', methods=["GET", "POST"])
def TaskEditor_Add():
state = "Add - Task"
if request.method == "POST":
title = request.form['title']
desc = request.form['desc']
if (title.isspace() or desc.isspace()):
state = "Invalid Task"
else:
task = Task(title=title, desc=desc)
db.session.add(task)
db.session.commit()
state = "Task added"
return redirect("/taskList")
return render_template('addTask.html', state=state)
# Update an existing todo area ================================
@app.route('/TaskEditor_Edit/<int:sno>', methods=["POST", "GET"])
def TaskEditor_Edit(sno):
task = Task.query.filter_by(sno=sno).first()
state="Edit Task"
if request.method == "POST":
title = request.form['title']
desc = request.form['desc']
if (title.isspace() or desc.isspace()):
state = "Invalid Task"
else:
task.title = title
task.desc = desc
db.session.add(task)
db.session.commit()
return redirect('/taskList')
return render_template('editTask.html', task=task, state=state)
if __name__ == "__main__":
app.run(debug=True) ```
The procfile only has this single line of code which is down below:
web:gunicorn app:app