2024-04-21 12:02:19 +02:00
|
|
|
---
|
2024-04-19 14:41:05 +02:00
|
|
|
# Kestra Python Command Template
|
|
|
|
# ---
|
2024-04-21 11:59:31 +02:00
|
|
|
#
|
2024-04-19 14:41:05 +02:00
|
|
|
# This template is a simple Python script that can be used to make a request to a website and log the status code.
|
2024-04-21 11:59:31 +02:00
|
|
|
#
|
2024-04-19 14:41:05 +02:00
|
|
|
|
|
|
|
id: python-script
|
2024-04-21 12:06:15 +02:00
|
|
|
namespace: # your-namespace
|
2024-04-19 14:41:05 +02:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
|
|
|
|
- id: python_script
|
|
|
|
type: io.kestra.plugin.scripts.python.Script
|
|
|
|
runner: DOCKER # (might be deprecated in the future) use TaskRunner instead
|
|
|
|
script: |
|
|
|
|
from kestra import Kestra
|
|
|
|
import requests
|
2024-04-21 11:59:31 +02:00
|
|
|
|
2024-04-19 14:41:05 +02:00
|
|
|
response = requests.get('{{inputs.website}}')
|
|
|
|
print(response.status_code)
|
2024-04-21 11:59:31 +02:00
|
|
|
|
2024-04-19 14:41:05 +02:00
|
|
|
Kestra.outputs({'status': response.status_code, 'text': response.text})
|
|
|
|
beforeCommands:
|
|
|
|
- pip install requests kestra
|
|
|
|
|
|
|
|
- id: log
|
|
|
|
type: io.kestra.core.tasks.log.Log
|
|
|
|
message: "StatusCode: {{outputs.pythonscript.vars.status}}"
|