Skip to content

Commit

Permalink
[IMP] Moved response into namespace blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
c8y3 committed Oct 9, 2024
1 parent 3e9627b commit 12204dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
9 changes: 8 additions & 1 deletion source/app/blueprints/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import json

from flask import render_template
from flask import request

from app import TEMPLATE_PATH
from app import app
from app.util import response
from app.util import AlchemyEncoder


# Set basic 404
Expand All @@ -34,6 +35,12 @@ def page_not_found(e):
return render_template('pages/error-404.html', template_folder=TEMPLATE_PATH), 404


def response(status, data=None):
if data is not None:
data = json.dumps(data, cls=AlchemyEncoder)
return app.response_class(response=data, status=status, mimetype='application/json')


def response_error(msg, data=None, status=400):
content = {
'status': 'error',
Expand Down
3 changes: 1 addition & 2 deletions source/app/blueprints/rest/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from functools import wraps

from app import app
from app.util import response
from app.blueprints.responses import response_error
from app.blueprints.responses import response_error, response

logger = app.logger

Expand Down
6 changes: 0 additions & 6 deletions source/app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
from app.models import Cases


def response(status, data=None):
if data is not None:
data = json.dumps(data, cls=AlchemyEncoder)
return app.response_class(response=data, status=status, mimetype='application/json')


def g_db_commit():
db.session.commit()

Expand Down

0 comments on commit 12204dc

Please sign in to comment.