"""
Goal: Init the Flask Singletons 'app' and 'db'
used by ../run.py

@authors:
  Andrei Sura             <sura.andrei@gmail.com>
  Ruchi Vivek Desai       <ruchivdesai@gmail.com>
  Sanath Pasumarthy       <sanath@ufl.edu>
"""

import time

try:
    from flask import Flask, g
    from flask_sqlalchemy import SQLAlchemy
except ImportError, error:
    import sys
    sys.exit("Missing required package: {}".format(error))


# The WSGI compliant web-application object
app = Flask(__name__)

# The Object-Relationan-Mapping (ORM) object
db = SQLAlchemy(app)



#@app.before_request
#def before_request():
#    """ Set a timer """
#    g.start = time.time()
#

#@app.after_request
#def after_request(response):
#    """
#    @TODO: log how long it took to parse the request
#    """
#    diff = time.time() - g.start
#    app.logger.debug("Exec time: {}".format(str(diff)))
#
#    if response.response and "__EXE_TIME__" in response.response:
#        response.response = response.response.replace(
#            '__EXE_TIME__', str(diff))
#        response.headers["content-length"] = len(response.response)
#
#    return response

#@app.teardown_request
#def end_of_request(exception=None):
#    """ Release resources """
#    if exception is not None:
#        app.logger.debug("end_of_request() exception: {}".format(exception))
#
#    if app.db_session is not None:
#        #app.logger.debug("removing session...")
#        app.db_session.remove()

@@ -225,21 +225,8 @@
 %22%22%0A%0A
-import time%0A%0A
 try:
@@ -257,11 +257,8 @@
 lask
-, g
 %0A   
@@ -538,898 +538,4 @@
 pp)%0A
-%0A%0A%0A#@app.before_request%0A#def before_request():%0A#    %22%22%22 Set a timer %22%22%22%0A#    g.start = time.time()%0A#%0A%0A#@app.after_request%0A#def after_request(response):%0A#    %22%22%22%0A#    @TODO: log how long it took to parse the request%0A#    %22%22%22%0A#    diff = time.time() - g.start%0A#    app.logger.debug(%22Exec time: %7B%7D%22.format(str(diff)))%0A#%0A#    if response.response and %22__EXE_TIME__%22 in response.response:%0A#        response.response = response.response.replace(%0A#            '__EXE_TIME__', str(diff))%0A#        response.headers%5B%22content-length%22%5D = len(response.response)%0A#%0A#    return response%0A%0A#@app.teardown_request%0A#def end_of_request(exception=None):%0A#    %22%22%22 Release resources %22%22%22%0A#    if exception is not None:%0A#        app.logger.debug(%22end_of_request() exception: %7B%7D%22.format(exception))%0A#%0A#    if app.db_session is not None:%0A#        #app.logger.debug(%22removing session...%22)%0A#        app.db_session.remove()%0A

Remove unused imports/code in main.py before/after request