from flask import abort, Blueprint, request, jsonify, session, make_response from sqlalchemy import func, or_, and_, text from imhm.tools import DB from imhm.tools import pre_request_logging, after_request_logging from imhm.tools import check_req_data, parse_session, admin_only, login_required from imhm.tools import StrCat from imhm.config import f401 from imhm.models import * # from imhm.utils.async.functions import mpush, check_bussiness_license music_bp = Blueprint(__name__, "music") app = music_bp db = DB.get_session() @app.teardown_request def teardown_request_sqlalchemy_session_remove(exception): try: db.remove() # print("teardown_request_sqlalchemy_session_remove : success") except Exception, e: # print("teardown_request_sqlalchemy_session_remove : %s" % str(e)) pass app.before_request(pre_request_logging) app.after_request(after_request_logging)
def make_shell_context(): return dict(app=app, db=DB.get_session(),)