summaryrefslogtreecommitdiffstats
path: root/api/server.py
diff options
context:
space:
mode:
authorJing Lu <lvjing5@huawei.com>2017-07-14 08:38:41 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-14 08:38:41 +0000
commitfb86be55d52f6cefd4e0de4b857ac76d00a9e681 (patch)
tree00dff5a143b5f3201c3b50e2f5fbb8949f1e3780 /api/server.py
parent80e57bf2264577cb08c2c347c7f0d272ee8d192f (diff)
parent933cf69b72bb61450ba5e4fa857303e2e05f95b3 (diff)
Merge "Initial all url of api v2"
Diffstat (limited to 'api/server.py')
-rw-r--r--api/server.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/api/server.py b/api/server.py
index c1548ca10..158b8a508 100644
--- a/api/server.py
+++ b/api/server.py
@@ -32,7 +32,7 @@ try:
except ImportError:
from urllib.parse import urljoin
-logger = logging.getLogger(__name__)
+LOG = logging.getLogger(__name__)
app = Flask(__name__)
@@ -62,7 +62,7 @@ def init_db():
return False
subclses = filter(func, inspect.getmembers(models, inspect.isclass))
- logger.debug('Import models: %s', [a[1] for a in subclses])
+ LOG.debug('Import models: %s', [a[1] for a in subclses])
Base.metadata.create_all(bind=engine)
@@ -77,12 +77,15 @@ def get_endpoint(url):
for u in urlpatterns:
- api.add_resource(get_resource(u.target), u.url, endpoint=get_endpoint(u.url))
+ try:
+ api.add_resource(get_resource(u.target), u.url, endpoint=get_endpoint(u.url))
+ except StopIteration:
+ LOG.error('url resource not found: %s', u.url)
if __name__ == '__main__':
_init_logging()
- logger.setLevel(logging.DEBUG)
- logger.info('Starting server')
+ LOG.setLevel(logging.DEBUG)
+ LOG.info('Starting server')
init_db()
app.run(host='0.0.0.0')