Skip to content

Commit 29e3646

Browse files
Chapter 17: Traditional hosting (17g)
1 parent 012263f commit 29e3646

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

config.py

+14
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,26 @@ def init_app(cls, app):
102102
app.logger.addHandler(file_handler)
103103

104104

105+
class UnixConfig(ProductionConfig):
106+
@classmethod
107+
def init_app(cls, app):
108+
ProductionConfig.init_app(app)
109+
110+
# log to syslog
111+
import logging
112+
from logging.handlers import SysLogHandler
113+
syslog_handler = SysLogHandler()
114+
syslog_handler.setLevel(logging.INFO)
115+
app.logger.addHandler(syslog_handler)
116+
117+
105118
config = {
106119
'development': DevelopmentConfig,
107120
'testing': TestingConfig,
108121
'production': ProductionConfig,
109122
'heroku': HerokuConfig,
110123
'docker': DockerConfig,
124+
'unix': UnixConfig,
111125

112126
'default': DevelopmentConfig
113127
}

flasky.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import os
2+
from dotenv import load_dotenv
3+
4+
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
5+
if os.path.exists(dotenv_path):
6+
load_dotenv(dotenv_path)
27

38
COV = None
49
if os.environ.get('FLASK_COVERAGE'):

requirements/common.txt

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Mako==1.0.7
2020
Markdown==2.6.8
2121
MarkupSafe==1.1.1
2222
python-dateutil==2.6.1
23+
python-dotenv==0.6.5
2324
python-editor==1.0.3
2425
six==1.10.0
2526
SQLAlchemy==1.1.11

0 commit comments

Comments
 (0)