Hello there.
I’m having a tough time in my first time with Render services (Web application with Python + Flask). Here is the application on Github: https://github.com/abcoo-ideias/portfolio
I’m trying to fix Gunicorn error messages. Check this out:
INFO==> Deploying...
INFO==> Using Node version 20.11.1 (default)
INFO==> Docs on specifying a Node version: https://render.com/docs/node-version
INFO==> Running 'gunicorn app:app'
INFOTraceback (most recent call last):
INFO File "/opt/render/project/src/.venv/bin/gunicorn", line 8, in <module>
INFO sys.exit(run())
INFO ^^^^^
INFO File "/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
INFO WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
INFO File "/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/base.py", line 236, in run
INFO super().run()
INFO File "/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/base.py", line 72, in run
INFO Arbiter(self).run()
Locally, everything goes fine, however it doesn’t even run here on Render.
My start command is gunicorn app:app, based on Render Docs to Python+Flask.
Right below, it’s a snippet of my main Python file, called app.py:
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy # Install = Flask-SQLAlchemy
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column # Install = SQLAlchemy
from sqlalchemy import Integer, String # Install = SQLAlchemy
from flask_bootstrap import Bootstrap5 # Install = Bootstrap-Flask
import os
from datetime import date
APP_SECRET_KEY = os.environ["APP_SECRET_KEY"]
# Creating the app:
app = Flask(__name__, template_folder="templates", static_folder="static")
app.config["SECRET_KEY"] = APP_SECRET_KEY
app.jinja_env.finalize = lambda x: x if x is not None else '' # make the jinja doesn't print out NONE values.
bootstrap = Bootstrap5(app)
You can check online the entire file on GitHub.
Current requirements.txt file:
Flask~=3.0.2
SQLAlchemy~=2.0.27
gunicorn~=21.2.0
Bootstrap-Flask~=2.3.3
Jinja2~=3.1.3
Some light on this topic would be very much appreciated, folks.
Cheers and crossed fingers.