script.yaml 782 B

12345678910111213141516171819202122232425262728
  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
  8. tasks:
  9. - id: python_script
  10. type: io.kestra.plugin.scripts.python.Script
  11. runner: DOCKER # (might be deprecated in the future) use TaskRunner instead
  12. script: |
  13. from kestra import Kestra
  14. import requests
  15. response = requests.get('{{inputs.website}}')
  16. print(response.status_code)
  17. Kestra.outputs({'status': response.status_code, 'text': response.text})
  18. beforeCommands:
  19. - pip install requests kestra
  20. - id: log
  21. type: io.kestra.core.tasks.log.Log
  22. message: "StatusCode: {{outputs.pythonscript.vars.status}}"