Skip to content
testfulvio.py 839 B
Newer Older
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''REST API test for Fulvio'''

# Third-party modules
from flask_restx import Namespace, Resource

# import devices

############################
# REST API
############################

api = Namespace('fulvio', description='Fulvio test')

@api.route("/test")
class TestApi(Resource):
    """First get/post test of Fulvio."""
Davide Ricci's avatar
Davide Ricci committed

    def get(self):
        """GET fulvio test."""
        res = {
            "response": "get ciao",
            "error": "",
        }
        return res

    def post(self):
        """POST fulvio test."""
        target = api.payload

        if target != "bbb":
            err = "Non va bene, scrivi bbb"
        else:
Davide Ricci's avatar
Davide Ricci committed
            err = "nessun errore"

        res = {
            "response": target,
            "error": err,
        }
        return res