예제 #1
0
def deleteHistoryItem(request):
    deleteSingleHistoryItem(request["username"], request["index"])
    #Run a new request through the interpreter, the front-end expects an entirely new list
    return formatResponse(commandInterpreter.parseCommand("history", request["username"]))
예제 #2
0
def newQuery(request):
    print(request)
    if (len(request["query"]) == 0):
        return formatResponse({
                             "success": "false"
                             })
    #Update the user's timeout period
    updateLastAction(request["username"])
    
    #Create the response object
    finalResponse = {}
    
    formattedQuery = formatInput(request["query"])
    
    #############################
    #START FUNCTION TYPE HANDLING
    if (formattedQuery["type"] == "function"):
        tokenizerResult = {}
        #Add the query to the user's history
        addToHistory(request["username"], request["query"])
        
        tokenizerResult = tokenizeInput(formattedQuery["functions"])

        rpnStack = postfixInput(tokenizerResult["tokens"])
        
        
        #Start 2D plot section
        if (tokenizerResult["dimension"] == 2):
            createTwoDWorkspace(finalResponse, rpnStack)
            
            
        ##################
        #End 2D plot section
        
        #Start 3D plot section
        if (tokenizerResult["dimension"] == 3):
            createThreeDWorkspace(finalResponse, rpnStack)
            
            
        #Format the original function into latex
        formattedInput = symPySolver.formatToLatex(formattedQuery["functions"])
        
        
        #Derivative and integral
        
        derivative = symPySolver.getDerivative(formattedQuery["functions"])
        
        integral = symPySolver.getIntegral(formattedQuery["functions"])
        
        
        
        finalResponse["formattedInput"] = formattedInput
        finalResponse["integral"] = integral
        finalResponse["derivative"] = derivative
        
        finalResponse["success"] = "true"
        
    
    #END FUNCTION TYPE HANDLING
    ###########################
    
    
    ############################
    #START COMMAND TYPE HANDLING
    else :
        commandResponse = commandInterpreter.parseCommand(formattedQuery["functions"], request["username"])
        finalResponse = commandResponse
    
    #END COMMAND TYPE HANDLING
    ##########################
    return(formatResponse(finalResponse))