python_script.yaml 744 B

123456789101112131415161718192021222324
  1. ---
  2. # Kestra Python Command Template
  3. # ---
  4. #
  5. # This template is a simple Python script that can be used to make a request to a website and log the status code.
  6. #
  7. id: python_script
  8. namespace: your_namespace # <-- Replace with your namespace...
  9. tasks:
  10. - id: python_job
  11. type: io.kestra.plugin.scripts.python.Script
  12. taskRunner:
  13. type: io.kestra.plugin.core.runner.Process
  14. script: |
  15. from kestra import Kestra
  16. import requests
  17. response = requests.get('{{inputs.website}}')
  18. print(response.status_code)
  19. Kestra.outputs({'status': response.status_code, 'text': response.text})
  20. - id: log
  21. type: io.kestra.plugin.core.log.Log
  22. message: "StatusCode: {{outputs.pythonscript.vars.status}}"