How to use the safrs.jsonapi_rpc function in safrs

To help you get started, we’ve selected a few safrs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thomaxxl / safrs / tests / relationship / demo_relationship.py View on Github external
    @jsonapi_rpc(http_methods=["POST"])
    def send_mail(self, **args):
        """
        description : Send an email
        args:
            email:
                type : string
                example : test email
        """
        return {"result": args}
github thomaxxl / safrs / examples / v1_examples / demo.py View on Github external
    @jsonapi_rpc(http_methods=["POST", "GET"])
    def send_mail(self, email):
        """
            description : Send an email
            args:
                email:
                    type : string 
                    example : test email
        """
        content = "Mail to {} : {}\n".format(self.name, email)
        with open("/tmp/mail.txt", "a+") as mailfile:
            mailfile.write(content)
        return {"result": "sent {}".format(content)}
github thomaxxl / safrs / examples / authentication / demo_auth.py View on Github external
    @jsonapi_rpc(http_methods=["POST"])
    def hash_password(self, password):
        self.password_hash = pwd_context.encrypt(password)
github thomaxxl / safrs / examples / demo_http_method.py View on Github external
    @jsonapi_rpc(http_methods=["POST", "GET"])
    def send_mail(self, email):
        """
            description : Send an email
            args:
                email:
                    type : string 
                    example : test email
        """
        content = "Mail to {} : {}\n".format(self.name, email)
        with open("/tmp/mail.txt", "a+") as mailfile:
            mailfile.write(content)
        return {"result": "sent {}".format(content)}
github thomaxxl / safrs / examples / authentication / demo_auth.py View on Github external
    @jsonapi_rpc(http_methods=["POST"])
    def verify_password(self, password):
        return pwd_context.verify(password, self.password_hash)
github thomaxxl / safrs / examples / v1_examples / demo_full.py View on Github external
    @jsonapi_rpc(http_methods=["GET"])
    def send_mail(self, email):
        """
            description : Send an email
            args:
                email:
                    type : string
                    example : test email
        """
        content = "Mail to {} : {}\n".format(self.name, email)
        with open("/tmp/mail.txt", "a+") as mailfile:
            mailfile.write(content)
        return {"result": "sent {}".format(content)}
github thomaxxl / safrs / examples / demo_pythonanywhere_com.py View on Github external
    @jsonapi_rpc(http_methods=["GET", "POST"])
    def my_rpc(cls, *args, **kwargs):
        """
            description : Generate and return a jsonapi-formatted response
            pageable: false
            parameters:
                - name : my_query_string_param
                  default : my_value
            args:
                email: test email
        """
        print(args)
        print(kwargs)
        result = cls
        response = SAFRSFormattedResponse()
        try:
            instances = result.query
github thomaxxl / safrs / examples / authentication / demo_auth.py View on Github external
    @jsonapi_rpc(http_methods=["POST"])
    def verify_auth_token(token):
        s = Serializer(app.config["SECRET_KEY"])
        try:
            data = s.loads(token)
        except SignatureExpired:
            return None  # valid token, but expired
        except BadSignature:
            return None  # invalid token
        user = User.query.get(data["username"])
        return user
github thomaxxl / safrs / examples / authentication / demo_auth.py View on Github external
    @jsonapi_rpc(http_methods=["POST"])
    def generate_auth_token(self, expiration=600):
        s = Serializer(app.config["SECRET_KEY"], expires_in=expiration)
        return s.dumps({"username": self.username})
github thomaxxl / safrs / examples / demo_pythonanywhere_com.py View on Github external
    @jsonapi_rpc(http_methods=["POST"])
    def send_mail(self, email):
        """
            description : Send an email
            args:
                email: test email
            parameters:
                - name : my_query_string_param
                  default : my_value
        """
        content = "Mail to {} : {}\n".format(self.name, email)
        with open("/tmp/mail.txt", "a+") as mailfile:
            mailfile.write(content)
        return {"result": "sent {}".format(content)}