knative-report-functions/isprime-python/app.py

23 lines
458 B
Python
Raw Normal View History

2019-10-08 18:16:16 +02:00
import os
from flask import Flask
app = Flask(__name__)
2019-10-10 15:34:57 +02:00
2019-10-08 18:16:16 +02:00
@app.route('/')
2019-10-08 18:42:36 +02:00
def isprime():
2019-10-10 15:34:57 +02:00
num = os.environ.get('TARGET', '107107')
if num > 1:
for i in range(2, num):
if (num % i) == 0:
return "not prime"
else:
return "not prime"
else:
print(num, "is not a prime number")
2019-10-08 18:16:16 +02:00
if __name__ == "__main__":
2019-10-10 15:34:57 +02:00
app.run(debug=True, host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))