Dateien für die Aufgabe 2.4: Netzwerke und Kommunikation zwischen Containern
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.py 652B

123456789101112131415161718192021222324252627
  1. # app.py
  2. from flask import Flask, request
  3. from werkzeug.urls import url_quote_plus
  4. app = Flask(__name__)
  5. def fizzbuzz(num):
  6. if num % 3 == 0 and num % 5 == 0:
  7. return "fizzbuzz"
  8. elif num % 3 == 0:
  9. return "fizz"
  10. elif num % 5 == 0:
  11. return "buzz"
  12. else:
  13. return str(num)
  14. @app.route('/fizzbuzz', methods=['POST'])
  15. def compute_fizzbuzz():
  16. data = request.json
  17. try:
  18. number = int(data['number'])
  19. return fizzbuzz(number)
  20. except (KeyError, ValueError):
  21. return "Invalid input: Please provide a valid number", 400
  22. if __name__ == '__main__':
  23. app.run(host='0.0.0.0', port=8080)