def tfi(): data = request.json base64Img = data['encodedImage'] res = ImgToText(base64Img) return ServerMethods.dispatchJSON({ 'equation': res._getEquation() })
def bjs(): data = request.json expression = data['expression'] fExpression, baseFormat = EquationFormating.defFormat(expression) res = Evaulute(buildTreeFromExpression(fExpression), baseFormat, fExpression)._getSelf() return ServerMethods.dispatchJSON({'base': res})
def sya(): data = request.json expression = data['expression'] res = f'{shuntingYardAlgorithmEvaluation(expression)}' return ServerMethods.dispatchJSON({ 'result': res, 'algorithm': 'shunting yard algorithm' })
def bte(): data = request.json expression = data['expression'] fExpression, baseFormat = EquationFormating.defFormat(expression) bTree = buildTreeFromExpression(fExpression) res = f'{Evaulute._evaluteAndGetOnlyResult(bTree)}' return ServerMethods.dispatchJSON({ 'result': res, 'algorithm': 'binary tree evaluation' })
def not_found(e): logging.error(e) return ServerMethods.dispatchJSON({ 'error': "404 route not found" })
def server_error(e): logging.error(e) return ServerMethods.dispatchJSON({ 'error': "500 internal error" })
def heartbeat(): return ServerMethods.dispatchJSON({ 'beat': True })