let debug configurable

This commit is contained in:
doanguyen 2020-01-05 19:45:29 +01:00
parent f62a7ffe47
commit 4e84815375
2 changed files with 7 additions and 4 deletions

View File

@ -30,6 +30,8 @@ COLOR_LOG = "COLOR_LOG" in os.environ
# Allow user to have 1 year of premium: set the expiration_date to 1 year more
PROMO_CODE = "SIMPLEISBETTER"
# Debug mode
DEBUG = os.environ['DEBUG']
# Server url
URL = os.environ["URL"]
print(">>> URL:", URL)

View File

@ -18,6 +18,7 @@ from app.admin_model import SLModelView, SLAdminIndexView
from app.api.base import api_bp
from app.auth.base import auth_bp
from app.config import (
DEBUG,
DB_URI,
FLASK_SECRET,
SENTRY_DSN,
@ -67,6 +68,8 @@ os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
def create_app() -> Flask:
app = Flask(__name__)
app.url_map.strict_slashes = False
app.debug = DEBUG
os.environ["FLASK_DEBUG"] = DEBUG
app.config["SQLALCHEMY_DATABASE_URI"] = DB_URI
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
@ -422,8 +425,6 @@ window.location.href = "/";
if __name__ == "__main__":
app = create_app()
app.debug = True
# enable flask toolbar
# app.config["DEBUG_TB_PROFILER_ENABLED"] = True
# app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = False
@ -444,6 +445,6 @@ if __name__ == "__main__":
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
context.load_cert_chain("local_data/cert.pem", "local_data/key.pem")
app.run(debug=True, host="0.0.0.0", port=7777, ssl_context=context)
app.run(host="0.0.0.0", port=7777, ssl_context=context)
else:
app.run(debug=True, host="0.0.0.0", port=7777)
app.run(host="0.0.0.0", port=7777)