forked from cycroo/fixhubs.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
50 lines (37 loc) · 1.34 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#-*- encoding: utf-8 -*-
#"/var/folders",
"""
Copyright (c) 2019 - present tanerjn.us
"""
import os
from flask_migrate import Migrate
from flask_minify import Minify
from sys import exit
from dotenv import load_dotenv
from apps.config import config_dict
from apps import create_app, db
import psycopg2
# WARNING: Don't run with debug turned on in production!
DEBUG = (os.getenv('DEBUG', 'False') == 'True')
# The configuration
get_config_mode = 'Debug' if DEBUG else 'Production'
try:
# Load the configuration using the default values
app_config = config_dict[get_config_mode.capitalize()]
except KeyError:
exit('Error: Invalid <config_mode>. Expected values [Debug, Production] ')
app = create_app(app_config)
Migrate(app, db)
url = os.getenv('PS URL')
connection = psycopg2.connect(url)
if not DEBUG:
Minify(app=app, html=True, js=False, cssless=False)
if DEBUG:
app.logger.info('DEBUG = ' + str(DEBUG) )
app.logger.info('FLASK_ENV = ' + os.getenv('FLASK_ENV') )
app.logger.info('POSTGRES = ' + os.getenv('PS_URL') )
app.logger.info('PAGE COMPRESSION = ' + 'FALSE' if DEBUG else 'TRUE' )
app.logger.info('SQLALCHEMY = ' + app_config.SQLALCHEMY_DATABASE_URI)
app.logger.info('ASSETS_ROOT = ' + app_config.ASSETS_ROOT )
if __name__ == "__main__":
app.app()