Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DeployREST.py #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions DeployREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)