aboutsummaryrefslogtreecommitdiffstats
path: root/api/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'api/views.py')
-rw-r--r--api/views.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/api/views.py b/api/views.py
new file mode 100644
index 000000000..883091222
--- /dev/null
+++ b/api/views.py
@@ -0,0 +1,29 @@
+import json
+import logging
+
+from flask import request
+from flask_restful import Resource
+
+from api.utils import common as common_utils
+from api.actions import test as test_action
+from api import conf
+
+logger = logging.getLogger(__name__)
+
+
+class Test(Resource):
+ def post(self):
+ action = common_utils.translate_to_str(request.json.get('action', ''))
+ args = common_utils.translate_to_str(request.json.get('args', {}))
+ logger.debug('Input args is: action: %s, args: %s', action, args)
+
+ if action not in conf.TEST_ACTION:
+ logger.error('Wrong action')
+ result = {
+ 'status': 'error',
+ 'message': 'wrong action'
+ }
+ return json.dumps(result)
+
+ method = getattr(test_action, action)
+ return method(args)