monkey/monkey_island/cc/resources/new_config.py

21 lines
493 B
Python
Raw Normal View History

2017-08-25 22:47:08 +08:00
import json
from flask import request
import flask_restful
from cc.database import mongo
__author__ = 'Barak'
class NewConfig(flask_restful.Resource):
def get(self):
config = mongo.db.config.find_one({'name': 'newconfig'}) or {}
if 'name' in config:
del config['name']
return config
def post(self):
config_json = json.loads(request.data)
return mongo.db.config.update({'name': 'newconfig'}, {"$set": config_json}, upsert=True)