Chapter 18: Deployment on Heroku (v0.18)
This commit is contained in:
parent
7d16e19169
commit
ae62fc9251
|
@ -0,0 +1 @@
|
|||
web: flask db upgrade; flask translate compile; gunicorn microblog:app
|
|
@ -68,6 +68,11 @@ def create_app(config_class=Config):
|
|||
mail_handler.setLevel(logging.ERROR)
|
||||
app.logger.addHandler(mail_handler)
|
||||
|
||||
if app.config['LOG_TO_STDOUT']:
|
||||
stream_handler = logging.StreamHandler()
|
||||
stream_handler.setLevel(logging.INFO)
|
||||
app.logger.addHandler(stream_handler)
|
||||
else:
|
||||
if not os.path.exists('logs'):
|
||||
os.mkdir('logs')
|
||||
file_handler = RotatingFileHandler('logs/microblog.log',
|
||||
|
|
|
@ -7,8 +7,10 @@ load_dotenv(os.path.join(basedir, '.env'))
|
|||
|
||||
class Config(object):
|
||||
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', '').replace(
|
||||
'postgres://', 'postgresql://') or \
|
||||
'sqlite:///' + os.path.join(basedir, 'app.db')
|
||||
LOG_TO_STDOUT = os.environ.get('LOG_TO_STDOUT')
|
||||
MAIL_SERVER = os.environ.get('MAIL_SERVER')
|
||||
MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25)
|
||||
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
|
||||
|
|
|
@ -37,3 +37,7 @@ typing_extensions==4.5.0
|
|||
urllib3==1.26.15
|
||||
Werkzeug==2.3.3
|
||||
WTForms==3.0.1
|
||||
|
||||
# requirements for Heroku
|
||||
psycopg2-binary==2.9.6
|
||||
gunicorn==20.1.0
|
||||
|
|
Loading…
Reference in New Issue