예제 #1
0
def updateTask():
    """
            ini adalah Endpoint untuk menginput data task.
            ---
            tags:
                - Rest Controller
            parameter:
                - in: path
                    name: id
                    required: true
                    type: integer
                - in: body
                    name: body
                    required: true
                    schema:
                        id: cereal
                        required:
                        - calories
                        - protein
                        - fat
                        - sodium
                        - fiber
                        - carbo
                        - potass
                        - vitamins
                    properties:
                        calories:
                            type: int
                            description: input with valid data
                            default: 0
                        protein:
                            type: int
                            description: input with valid data
                            default: 0
                        fat:
                            type: int
                            description: input with valid data
                            default: 0
                        sodium:
                            type: int
                            description: input with valid data
                            default: 0
                        fiber:
                            type: int
                            description: input with valid data
                            default: 0
                        carbo:
                            type: int
                            description: input with valid data
                            default: 0
                        potass:
                            type: int
                            description: input with valid data
                            default: 0
                        vitamins:
                            type: int
                            description: input with valid data
                            default: 0
            responses:
                200:
                    description: Success Update
            """
    new_task = request.get_json()

    calories = new_task['calories']
    protein = new_task['protein']
    fat = new_task['fat']
    sodium = new_task['sodium']
    fiber = new_task['fiber']
    carbo = new_task['carbo']
    potass = new_task['potass']
    vitamins = new_task['vitamins']

    newcereal = cereal(calories,  protein,  fat,  sodium,  fiber,  carbo,  potass,  vitamins)

    tasks[id] = newcereal.__dict__
예제 #2
0
def inputTask():
    """
        ini adalah Endpoint untuk menginput data task.
        ---
        tags:
            - Rest Controller
        parameter:
            - name: body
                in: body
                required: true
                schema:
                    id: product
                    required:
                    - calories
                    - protein
                    - fat
                    - sodium
                    - fiber
                    - carbo
                    - potass
                    - vitamins
                properties:
                    calories:
                        type: int
                        description: input with valid data
                        default: 0
                    protein:
                        type: int
                        description: input with valid data
                        default: 0
                    fat:
                        type: int
                        description: input with valid data
                        default: 0
                    sodium:
                        type: int
                        description: input with valid data
                        default: 0
                    fiber:
                        type: int
                        description: input with valid data
                        default: 0
                    carbo:
                        type: int
                        description: input with valid data
                        default: 0
                    potass:
                        type: int
                        description: input with valid data
                        default: 0
                    vitamins:
                        type: int
                        description: input with valid data
                        default: 0
        responses:
            200:
                description: Success Input
        """
    newData = request.get_json()

    calories = newData['calories']
    protein = newData['protein']
    fat = newData['fat']
    sodium = newData['sodium']
    fiber = newData['fiber']
    carbo = newData['carbo']
    potass = newData['potass']
    vitamins = newData['vitamins']

    newcereal = cereal(calories,  protein,  fat,  sodium,  fiber,  carbo,  potass,  vitamins)

    tasks.append(newcereal.__dict__)

    return jsonify({'message': 'success'})
예제 #3
0
from Model.cereal import cereal

dummy1 = cereal(1, 2, 3, 4, 5, 6, 7, 8)
dummy2 = cereal(9, 10, 11, 12, 13, 14, 15, 16)

tasks = [dummy1.__dict__, dummy2.__dict__]