From 51099504e36b31e904c6356946ff51d37125fbef Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Wed, 12 Feb 2020 16:05:30 +0200 Subject: [PATCH] Revert "Added before/after request handlers that add the execution time" This reverts commit 424784ee45f9f9d6739303f64abc08c5ea3e1905. --- monkey/monkey_island/cc/app.py | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 4c5c64ec8..be2430dda 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -1,11 +1,8 @@ -import json -import logging import os -import time import uuid import flask_restful -from flask import Flask, send_from_directory, Response, g +from flask import Flask, send_from_directory, Response from werkzeug.exceptions import NotFound from monkey_island.cc.auth import init_jwt @@ -44,8 +41,6 @@ __author__ = 'Barak' HOME_FILE = 'index.html' -logger = logging.getLogger(__name__) - def serve_static_file(static_path): if static_path.startswith('api/'): @@ -124,25 +119,6 @@ def init_api_resources(api): api.add_resource(LogTest, '/api/test/log') -def init_app_execution_time_calc(app): - @app.before_request - def before_request(): - g.start = time.time() - logger.debug("inb4 next request?") - - @app.after_request - def after_request(response): - diff_in_ms = int((time.time() - g.start)*1000) - logger.debug(f"After request") - if response.response: - if response.content_type == "application/json": - response_data = json.loads(response.get_data()) - if isinstance(response_data, dict): - response_data["execution_time_ms"] = diff_in_ms - response.set_data(json.dumps(response_data)) - return response - - def init_app(mongo_url): app = Flask(__name__) @@ -152,7 +128,6 @@ def init_app(mongo_url): init_app_config(app, mongo_url) init_app_services(app) init_app_url_rules(app) - init_app_execution_time_calc(app) init_api_resources(api) return app