From da46cf114a6b18d83bdc4ff2351f0ff4d5cf0d0c Mon Sep 17 00:00:00 2001 From: "Sachin S. Kamath" <sskamath96@gmail.com> Date: Mon, 30 Oct 2017 19:34:55 +0530 Subject: [PATCH] Add warning of unsafe work environment Signed-off-by: Sachin S. Kamath <sskamath96@gmail.com> --- hodor/__init__.py | 9 ++++++--- hodor/controllers/user.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hodor/__init__.py b/hodor/__init__.py index a9ec7a8..e20e725 100644 --- a/hodor/__init__.py +++ b/hodor/__init__.py @@ -1,5 +1,8 @@ # -*- coding: utf-8 -*- # app/__init__.py +import os +import sys +import time from termcolor import colored from flask_api import FlaskAPI from flask_sqlalchemy import SQLAlchemy @@ -23,14 +26,14 @@ application.config['SECRET_KEY'] = 'blehblehbleh' # Delay the application launch to get the user attention if running in # testing mode -''' -if config_name != 'production': + +if config_name != 'production' and not os.getenv('SKIP_COUNT'): for x in range(0, 5): sys.stdout.write(colored("\rYou are not running the server in production mode. " + "App will run in {} seconds..".format(5-x), 'red')) sys.stdout.flush() time.sleep(1) -''' + print(colored("\n\nRunning app in {} mode..".format(config_name), 'yellow')) # This disables the HTML API renderer for flask_api when called through diff --git a/hodor/controllers/user.py b/hodor/controllers/user.py index 9437491..92bb5d7 100644 --- a/hodor/controllers/user.py +++ b/hodor/controllers/user.py @@ -145,7 +145,7 @@ def handle_sql_assertion_error(err): errmsg = err.orig.args[0].split('\n') except IndexError: errmsg = err.orig.args[0] - + return make_response(jsonify(status=400, msg=errmsg), 400) -- GitLab