script.yaml 856 B

1234567891011121314151617181920212223242526272829
  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 # <- Replace with your task id...
  8. namespace: your-namespace # <- Replace with your namespace...
  9. tasks:
  10. - id: python_script
  11. type: io.kestra.plugin.scripts.python.Script
  12. runner: DOCKER # (might be deprecated in the future) use TaskRunner instead
  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. beforeCommands:
  20. - pip install requests kestra
  21. - id: log
  22. type: io.kestra.core.tasks.log.Log
  23. message: "StatusCode: {{outputs.pythonscript.vars.status}}"