def post(self): """ create a environment /environment/ :return: """ super(ServerAPI, self).post() form = ServerForm(request.form, csrf_enabled=False) if form.validate_on_submit(): server_new = ServerModel() id = server_new.add(name=form.name.data, host=form.host.data) if not id: return self.render_json(code=-1) return self.render_json(data=server_new.item(id)) else: return self.render_json(code=-1, message=form.errors)
def post(self): """ create a environment /environment/ :return: """ super(ServerAPI, self).post() form = ServerForm(request.form, csrf_enabled=False) if form.validate_on_submit(): server_new = ServerModel() id = server_new.add(name=form.name.data, host=form.host.data) if not id: return self.render_json(code=-1) return self.render_json(data=server_new.item(id)) else: return self.render_json(Code.form_error, message=form.errors)
def post(self): """ create a server /server/ :return: """ super(ServerAPI, self).post() form = ServerForm(request.form, csrf=False) if form.validate_on_submit(): server_new = ServerModel() data = form.form2dict() id = server_new.add(data) if not id: return self.render_json(code=-1) return self.render_json(data=server_new.item(id)) else: return self.render_json(Code.form_error, message=form.errors)