# ------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------------------------------

import flask
from flask import request, jsonify
from flask_cors import CORS
import math
import sys
import time

app = flask.Flask(__name__)
CORS(app)

@app.route('/multiply', methods=['POST'])
def multiply():
    ######################################################
    # Adding this call to sleep() to slow down the multipier
    time.sleep(1)
    ######################################################
    content = request.json
    [operand_one, operand_two] = [float(content['operandOne']), float(content['operandTwo'])]
    print(f"Calculating {operand_one} * {operand_two}", flush=True)
    return jsonify(math.ceil(operand_one * operand_two * 100000)/100000)

app.run()