diff --git a/src/resources.py b/src/resources.py index a0a04b3..62b6afb 100644 --- a/src/resources.py +++ b/src/resources.py @@ -3,13 +3,12 @@ import logging import json from xeger import Xeger from flask_restful import Resource -from flask import request +from flask import request, current_app import requests from db import db from models import SampleMetadata from schemas import SampleSchema, SampleMetadataSchema from config import * -from app import app from fpika import fpika """ @@ -47,14 +46,14 @@ class SampleResource(Resource): description = request.form.get("description") if soundfile.content_type != 'audio/wave': - app.logger.info( + current_app.logger.info( f"Input file was not WAV.") return {'err_msg': 'Input file not a wave file.'}, 415 try: desc = self.sampleschema.loads(description) except Exception as e: - app.logger.exception(e) + current_app.logger.exception(e) return {'err_msg': 'Input JSON schema invalid'}, 417 xeger = Xeger(limit=30) @@ -83,7 +82,7 @@ class SampleResource(Resource): body=json.dumps({'tag': generated_tag}).encode('UTF-8')) fpika.return_channel(ch) except Exception as e: - app.logger.exception(e) + current_app.logger.exception(e) db.session.rollback() return {"err_msg": str( e), "hint": "DB or downstream service error"}, 569