monkey/monkey_island/cc/resources/monkey_configuration.py

24 lines
590 B
Python
Raw Normal View History

2017-08-29 19:12:07 +08:00
import json
from flask import request, jsonify
import flask_restful
from cc.database import mongo
from cc.services.config import ConfigService
2017-08-29 19:12:07 +08:00
__author__ = 'Barak'
class MonkeyConfiguration(flask_restful.Resource):
def get(self):
return jsonify(schema=ConfigService.get_config_schema(), configuration=ConfigService.get_config())
2017-08-29 19:12:07 +08:00
def post(self):
config_json = json.loads(request.data)
2017-09-21 22:32:36 +08:00
if config_json.has_key('reset'):
ConfigService.reset_config()
else:
ConfigService.update_config(config_json)
return self.get()
2017-08-29 19:12:07 +08:00