python_script.yaml 740 B

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