From 5da5070580dfef6d794a4ff94379dfbd7834bf24 Mon Sep 17 00:00:00 2001 From: "Sachin S. Kamath" <sskamath96@gmail.com> Date: Thu, 19 Oct 2017 19:22:03 +0530 Subject: [PATCH] Better warnings for mode Signed-off-by: Sachin S. Kamath <sskamath96@gmail.com> --- hodor/__init__.py | 10 +++++++--- hodor/api/__init__.py | 0 hodor/api/user.py | 12 ------------ hodor/app.py | 21 --------------------- 4 files changed, 7 insertions(+), 36 deletions(-) delete mode 100644 hodor/api/__init__.py delete mode 100644 hodor/api/user.py delete mode 100644 hodor/app.py diff --git a/hodor/__init__.py b/hodor/__init__.py index 9b9b1ba..cdcc372 100644 --- a/hodor/__init__.py +++ b/hodor/__init__.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- # app/__init__.py import time -import copy +from termcolor import colored +import sys from flask_api import FlaskAPI from flask_sqlalchemy import SQLAlchemy # local import @@ -24,10 +25,13 @@ db.init_app(application) # Delay the application launch to get the user attention if running in testing mode if config_name != 'production': for x in range(0, 5): - print("You are not running the server in production mode.\ - App will run in {} seconds".format(5-x)) + 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 browsers. if config_name == 'production': application.config['DEFAULT_RENDERERS'] = [ diff --git a/hodor/api/__init__.py b/hodor/api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/hodor/api/user.py b/hodor/api/user.py deleted file mode 100644 index 2075c09..0000000 --- a/hodor/api/user.py +++ /dev/null @@ -1,12 +0,0 @@ -from hodor.app import api -from flask_restplus import Resource - -ns = api.namespace('/users', description='Operations related to blog posts') - -@ns.route('/users') -class listusers(Resource): - def get(self): - return {'user': 'noob'} - - -api.add_resource(listusers, '/users') \ No newline at end of file diff --git a/hodor/app.py b/hodor/app.py deleted file mode 100644 index 0f402ea..0000000 --- a/hodor/app.py +++ /dev/null @@ -1,21 +0,0 @@ -from flask import Flask, request -from flask_restplus import Resource, Api -from api.user import ns as user_namespace - -app = Flask(__name__) -api = Api(app) - -todos = {} - -@api.route('/<string:todo_id>') -class TodoSimple(Resource): - def get(self, todo_id): - return {todo_id: todos[todo_id]} - - def put(self, todo_id): - todos[todo_id] = request.form['data'] - return {todo_id: todos[todo_id]} - -api.add_namespace(user_namespace) -if __name__ == '__main__': - app.run(debug=True) \ No newline at end of file -- GitLab