示例#1
0
文件: flags.py 项目: hitgo00/i_sploit
    def get(self):
        flags = Flags.query.all()
        schema = FlagSchema(many=True)
        response = schema.dump(flags)
        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        return {"success": True, "data": response.data}
示例#2
0
    def get(self):
        flags = Flags.query.all()
        schema = FlagSchema(many=True)
        response = schema.dump(flags)
        if response.errors:
            return {'success': False, 'errors': response.errors}, 400

        return {'success': True, 'data': response.data}
示例#3
0
    def get(self, challenge_id):
        flags = Flags.query.filter_by(challenge_id=challenge_id).all()
        schema = FlagSchema(many=True)
        response = schema.dump(flags)

        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        return {"success": True, "data": response.data}
示例#4
0
文件: flags.py 项目: hitgo00/i_sploit
    def get(self, flag_id):
        flag = Flags.query.filter_by(id=flag_id).first_or_404()
        schema = FlagSchema()
        response = schema.dump(flag)

        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        response.data["templates"] = get_flag_class(flag.type).templates

        return {"success": True, "data": response.data}
示例#5
0
    def get(self, flag_id):
        flag = Flags.query.filter_by(id=flag_id).first_or_404()
        schema = FlagSchema()
        response = schema.dump(flag)

        if response.errors:
            return {'success': False, 'errors': response.errors}, 400

        response.data['templates'] = get_flag_class(flag.type).templates

        return {'success': True, 'data': response.data}
示例#6
0
文件: flags.py 项目: KaitoRyouga/CTFd
    def get(self, query_args):
        q = query_args.pop("q", None)
        field = str(query_args.pop("field", None))
        filters = build_model_filters(model=Flags, query=q, field=field)

        flags = Flags.query.filter_by(**query_args).filter(*filters).all()
        schema = FlagSchema(many=True)
        response = schema.dump(flags)
        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        return {"success": True, "data": response.data}
示例#7
0
文件: flags.py 项目: hitgo00/i_sploit
    def post(self):
        req = request.get_json()
        schema = FlagSchema()
        response = schema.load(req, session=db.session)

        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        db.session.add(response.data)
        db.session.commit()

        response = schema.dump(response.data)
        db.session.close()

        return {"success": True, "data": response.data}
示例#8
0
文件: flags.py 项目: hitgo00/i_sploit
    def patch(self, flag_id):
        flag = Flags.query.filter_by(id=flag_id).first_or_404()
        schema = FlagSchema()
        req = request.get_json()

        response = schema.load(req, session=db.session, instance=flag, partial=True)

        if response.errors:
            return {"success": False, "errors": response.errors}, 400

        db.session.commit()

        response = schema.dump(response.data)
        db.session.close()

        return {"success": True, "data": response.data}