removed usage of bottle for handling exceptions for rest api

This commit is contained in:
bharnden 2018-10-16 09:42:43 -07:00
parent 9b8f2868fd
commit 8d610c99e9
3 changed files with 9 additions and 9 deletions

10
.gitignore vendored
View file

@ -8,6 +8,7 @@ Makefile
Makefile.in Makefile.in
aclocal.m4 aclocal.m4
autom4te.cache autom4te.cache
/config
config.h config.h
config.h.in config.h.in
config.log config.log
@ -16,8 +17,11 @@ configure
debian debian
stamp-h1 stamp-h1
# python build directory # python
dist dist
*.egg-info
.cache
*.pyc
# intellij # intellij
*.iml *.iml
@ -30,16 +34,12 @@ dist
coverage.xml coverage.xml
# python files # python files
*.egg-info
# ignore package files # ignore package files
*.rpm *.rpm
*.deb *.deb
*.tar.gz *.tar.gz
# pytest cache files
.cache
# ignore swap files # ignore swap files
*.swp *.swp

View file

@ -1,9 +1,9 @@
import os import os
from bottle import HTTPError
from flask import Flask from flask import Flask
from flask import jsonify from flask import jsonify
from flask import request from flask import request
from werkzeug.exceptions import HTTPException
import core_utils import core_utils
import emane_routes import emane_routes
@ -78,9 +78,9 @@ def upload():
return jsonify() return jsonify()
@app.errorhandler(HTTPError) @app.errorhandler(HTTPException)
def handle_error(e): def handle_error(e):
return jsonify(message=e.body, status=e.status_code), e.status_code return jsonify(message=e.description, status=e.code), e.code
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -2,7 +2,7 @@ import os
from functools import wraps from functools import wraps
from threading import Lock from threading import Lock
from bottle import abort from werkzeug.exceptions import abort
save_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "uploads") save_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "uploads")
CORE_LOCK = Lock() CORE_LOCK = Lock()