From 68fde29bdcfe0b206f588dab85e5b7d8ac9449f4 Mon Sep 17 00:00:00 2001 From: Leo Wang Date: Wed, 16 Nov 2016 22:44:23 -0500 Subject: Backend rest api mechanism JIRA:DOVETAIL-63 provide rest api as the dashboard backend 1. using gunicorn as rest api server 2. using flask as rest api framework 3. using sqlalchemy as mysql database driver 4. implement basic report CRUD operations 5. implement basic session management in database operations Change-Id: Ifbd251462396c2cb414b1ae9150cfc1e2e2d00c0 Signed-off-by: Leo Wang --- dashboard/backend/wsgi.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 dashboard/backend/wsgi.py (limited to 'dashboard/backend/wsgi.py') diff --git a/dashboard/backend/wsgi.py b/dashboard/backend/wsgi.py new file mode 100755 index 00000000..088299d7 --- /dev/null +++ b/dashboard/backend/wsgi.py @@ -0,0 +1,35 @@ +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +from dovetail.utils import flags +from dovetail.utils import logsetting +from dovetail.utils import setting_wrapper as setting + +from dovetail.api.api import app + +import os +import logging + +gunicorn_error_logger = logging.getLogger('gunicorn.error') +app.logger.handlers.extend(gunicorn_error_logger.handlers) +app.logger.setLevel(logging.DEBUG) + +# flags.init() +# logdir = setting.DEFAULT_LOGDIR +curr_path = os.path.dirname(os.path.abspath(__file__)) +logdir = os.path.join(curr_path, 'log') +if not os.path.exists(logdir): + os.makedirs(logdir) + +flags.OPTIONS.logdir = logdir +flags.OPTIONS.logfile = setting.WEB_LOGFILE +logsetting.init() + + +if __name__ == "__main__": + app.run() -- cgit 1.2.3-korg