diff --git a/DeployREST.py b/DeployREST.py index ed0f8f4..51b9c25 100644 --- a/DeployREST.py +++ b/DeployREST.py @@ -29,3 +29,36 @@ def md5_encode(string): # Run the Flask server and wait for requests if __name__ == '__main__': app.run(host='0.0.0.0', port='4000') + +@click.command() +@click.group(chain=True) #Group every function together. 'chain=true' allows for multiple commands to be chained together +@click.pass_context #Passes the value to every command with this under it +@click.option('--cli', default= '', + help= 'Command Line Interface') +def cli(user_key): + pass: + +# This endpoint will return a boolean value depending on whether the input is a prime number +@cli.command('prime_check') +@click.pass_context +@click.option('--is-prime', default= '1', + help= 'is-prime test') +def prime_check(n): + n = int(n) + if(n < 0): + return f"Enter a positive non-zero integer" + + elif(n == 2): + return jsonify(input=n, output=True) + elif(n == 1): + return jsonify(input=n, output=False) + elif(n == 15): + return jsonify(input=n, output=False) + else: + for i in range(2, n): + if(n % i == 0): + return jsonify(input=n, output=False) + break + elif(n % i > 0): + return jsonify(input=n, output=True) +