\\\",\\n \\\"css_content\\\" : \\\".tweet-text{background-color:#fff2ac;background-image:linear-gradient(to right,#ffe359 0,#fff2ac 100%);font-weight:bolder;font-size:32px;font-family:Roboto,sans-serif;padding:4px}\\\",\\n \\\"generate_img_url\\\": true\\n}\",\"__typename\":\"OauthBody\"},\"bodyParams\":[],\"authorization\":{\"type\":null,\"basicUsername\":\"\",\"basicPassword\":\"\",\"bearerToken\":\"\",\"oauthAccessToken\":null,\"oauthRefreshToken\":null,\"oauthSignerUri\":null,\"__typename\":\"Authorization\"},\"extracts\":[],\"metadataExtracts\":[],\"cellParams\":[],\"tab\":\"Body\",\"__typename\":\"OauthReq\"},\"marketplaceContent\":null,\"integrationConnections\":{\"nodes\":[],\"__typename\":\"IntegrationConnection\"}},\"otherApp\":{\"id\":\"app_m9zhdv\",\"name\":\"Python\",\"nameSlug\":\"python\",\"description\":\"Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.\",\"appPrompts\":[],\"authType\":null,\"customFieldsDescriptionMd\":\"\",\"oauthScopes\":[],\"customFields\":[],\"oauthReqsByType\":{\"requestToken\":{\"httpMethod\":\"POST\",\"url\":\"\",\"urlParams\":[],\"headerParams\":[],\"body\":null,\"bodyParams\":[],\"authorization\":{\"type\":\"OAuth\",\"basicUsername\":\"\",\"basicPassword\":\"\",\"bearerToken\":\"\",\"oauthAccessToken\":null,\"oauthRefreshToken\":null,\"oauthSignerUri\":null,\"__typename\":\"Authorization\"},\"extracts\":[],\"metadataExtracts\":null,\"cellParams\":null,\"tab\":null,\"__typename\":\"OauthReq\"},\"authorization\":{\"httpMethod\":\"GET\",\"url\":\"\",\"urlParams\":[{\"key\":\"client_id\",\"value\":\"{{oauth.client_id}}\",\"__typename\":\"Kv\"},{\"key\":\"redirect_uri\",\"value\":\"{{oauth.redirect_uri}}\",\"__typename\":\"Kv\"},{\"key\":\"state\",\"value\":\"{{oauth.state}}\",\"__typename\":\"Kv\"},{\"key\":\"response_type\",\"value\":\"code\",\"__typename\":\"Kv\"},{\"key\":\"scope\",\"value\":\"{{oauth.space_separated_scopes}}\",\"__typename\":\"Kv\"}],\"headerParams\":[],\"body\":null,\"bodyParams\":[],\"authorization\":{\"type\":null,\"basicUsername\":\"\",\"basicPassword\":\"\",\"bearerToken\":\"\",\"oauthAccessToken\":null,\"oauthRefreshToken\":null,\"oauthSignerUri\":null,\"__typename\":\"Authorization\"},\"extracts\":[],\"metadataExtracts\":null,\"cellParams\":null,\"tab\":null,\"__typename\":\"OauthReq\"},\"accessToken\":{\"httpMethod\":\"POST\",\"url\":\"\",\"urlParams\":[],\"headerParams\":[{\"key\":\"content-type\",\"value\":\"application/x-www-form-urlencoded\",\"__typename\":\"Kv\"},{\"key\":\"accept\",\"value\":\"application/json\",\"__typename\":\"Kv\"}],\"body\":null,\"bodyParams\":[{\"key\":\"client_id\",\"value\":\"{{oauth.client_id}}\",\"__typename\":\"Kv\"},{\"key\":\"client_secret\",\"value\":\"{{oauth.client_secret}}\",\"__typename\":\"Kv\"},{\"key\":\"redirect_uri\",\"value\":\"{{oauth.redirect_uri}}\",\"__typename\":\"Kv\"},{\"key\":\"grant_type\",\"value\":\"authorization_code\",\"__typename\":\"Kv\"},{\"key\":\"code\",\"value\":\"{{oauth.code}}\",\"__typename\":\"Kv\"}],\"authorization\":{\"type\":null,\"basicUsername\":\"\",\"basicPassword\":\"\",\"bearerToken\":\"\",\"oauthAccessToken\":null,\"oauthRefreshToken\":null,\"oauthSignerUri\":null,\"__typename\":\"Authorization\"},\"extracts\":[],\"metadataExtracts\":null,\"cellParams\":null,\"tab\":null,\"__typename\":\"OauthReq\"},\"refreshToken\":{\"httpMethod\":\"POST\",\"url\":\"\",\"urlParams\":[],\"headerParams\":[{\"key\":\"content-type\",\"value\":\"application/x-www-form-urlencoded\",\"__typename\":\"Kv\"},{\"key\":\"accept\",\"value\":\"application/json\",\"__typename\":\"Kv\"}],\"body\":null,\"bodyParams\":[{\"key\":\"client_id\",\"value\":\"{{oauth.client_id}}\",\"__typename\":\"Kv\"},{\"key\":\"client_secret\",\"value\":\"{{oauth.client_secret}}\",\"__typename\":\"Kv\"},{\"key\":\"grant_type\",\"value\":\"refresh_token\",\"__typename\":\"Kv\"},{\"key\":\"refresh_token\",\"value\":\"{{oauth.refresh_token}}\",\"__typename\":\"Kv\"}],\"authorization\":{\"type\":null,\"basicUsername\":\"\",\"basicPassword\":\"\",\"bearerToken\":\"\",\"oauthAccessToken\":null,\"oauthRefreshToken\":null,\"oauthSignerUri\":null,\"__typename\":\"Authorization\"},\"extracts\":[],\"metadataExtracts\":null,\"cellParams\":null,\"tab\":null,\"__typename\":\"OauthReq\"},\"__typename\":\"OauthReqsByType\"},\"__typename\":\"App\",\"registryComponents\":[{\"id\":\"sc_EgirZeao\",\"key\":\"python-run-python-code\",\"name\":\"Run Python Code\",\"description\":\"Write Python and use any of the 350k+ PyPi packages available. Refer to the [Pipedream Python docs](https://pipedream.com/docs/code/python) to learn more.\",\"type\":\"ACTION\",\"__typename\":\"SavedComponent\"}],\"componentCodeScaffoldRaw\":\"def handler(pd: \\\"pipedream\\\"):\\n # Reference data from previous steps\\n print(pd.steps[\\\"trigger\\\"][\\\"context\\\"][\\\"id\\\"])\\n # Return data for use in future steps\\n return {\\\"foo\\\": {\\\"test\\\":True}}\",\"testRequest\":{\"httpMethod\":\"GET\",\"url\":\"\",\"urlParams\":[],\"headerParams\":[],\"body\":null,\"bodyParams\":[],\"authorization\":{\"type\":null,\"basicUsername\":\"\",\"basicPassword\":\"\",\"bearerToken\":\"\",\"oauthAccessToken\":null,\"oauthRefreshToken\":null,\"oauthSignerUri\":null,\"__typename\":\"Authorization\"},\"extracts\":[],\"metadataExtracts\":[],\"cellParams\":[],\"tab\":null,\"__typename\":\"OauthReq\"},\"marketplaceContent\":{\"id\":\"873\",\"markdown\":\"# Overview\\n\\nDevelop, run and deploy your Python code in Pipedream workflows. Integrate seamlessly between no-code steps, with [connected accounts]([https://pipedream.com/docs/code/python/auth](https://pipedream.com/docs/code/nodejs/auth)), or integrate [Data Stores](https://pipedream.com/docs/data-stores) and [manipulate files within a workflow](https://pipedream.com/docs/code/python/working-with-files).\\n\\nThis includes [installing PyPI packages](https://pipedream.com/docs/code/python#using-third-party-packages), within your code without having to manage a `requirements.txt` file or running `pip`.\\n\\nBelow is an example of using Python to access data from the trigger of the workflow, and sharing it with subsequent workflow steps:\\n\\n# Example Use Cases\\n\\nHere are three practical uses for incorporating Python code in Pipedream workflows:\\n\\n1. **Automated Data Processing**:\\n - Python can be utilized within Pipedream to automate the processing of incoming data from various sources such as webhooks, APIs, or even scheduled events. You can transform, sanitize, and aggregate this data before passing it to subsequent steps or storing it in databases or data stores provided by Pipedream. This is particularly useful for workflows involving data analytics, where Python’s extensive library ecosystem (e.g., [Pandas](https://pandas.pydata.org/docs/user_guide/index.html) for data manipulation) can be leveraged.\\n2. **Integration and API Interactions**:\\n - Use Python to orchestrate complex API interactions that require custom logic beyond simple HTTP requests. This can include handling authentication flows, error processing, or managing pagination. Python’s robust support for network and protocol management makes it ideal for integrating disparate systems, performing API health checks, or even creating composite APIs that aggregate data from multiple sources into a unified response.\\n3. **Machine Learning and AI**:\\n - Implement machine learning models directly within your workflows to perform real-time predictions, analyses, or automated decision-making based on the incoming data streams. Python’s compatibility with machine learning frameworks like [TensorFlow](https://www.tensorflow.org/learn) or [scikit-learn](https://scikit-learn.org/stable/) allows you to import pre-trained models or train them on-the-fly using workflow data. This can be applied in scenarios such as image recognition, predictive maintenance, or customer sentiment analysis.\\n\\nThese applications of Python in Pipedream workflows enable sophisticated data operations, extend functionality with external APIs, and incorporate advanced analytics and machine learning directly into your automated processes.\\n\\n# Getting Started\\n\\nTo add a Python code step, open a new workflow and include a step.\\n\\n1. Select the Python app:\\n\\n\\n\\n2. Then select the **Run Python Code** action:\\n\\n\\n\\nNow you’re ready to write some code!\\n\\nOn the right, you'll see the default code provided by Pipedream:\\n\\n```python\\ndef handler(pd: \\\"pipedream\\\"):\\n # Reference data from previous steps\\n print(pd.steps[\\\"trigger\\\"][\\\"context\\\"][\\\"id\\\"])\\n # Return data for use in future steps\\n return {\\\"foo\\\": {\\\"test\\\": True}}\\n```\\n\\nYou can write your custom code within the `handler` function. `handler` is called when this step executes in your workflow. The **`pd`** argument contains the workflow's context and data.\\n\\nWhen you click **Test** on the Python code step, it will display the event data from your trigger step. For instance, if your trigger is an HTTP request, then the HTTP request data will be returned.\\n\\nThis step can execute any Python code. However, the `handler` function, a special Pipedream callback, must be set up correctly to return data. Otherwise, you can run arbitrary code that:\\n\\n* [Consume or share data with other steps](https://pipedream.com/docs/code/python#sharing-data-between-steps)\\n\\n- [Send HTTP requests]([https://pipedream.com/docs/code/python#making-http-requests-from-your-workflow](https://pipedream.com/docs/code/nodejs#making-http-requests-from-your-workflow))\\n- [Return an HTTP response]([https://pipedream.com/docs/code/python#returning-http-responses](https://pipedream.com/docs/code/nodejs#returning-http-responses))\\n- [End the entire workflow]([https://pipedream.com/docs/code/python#ending-a-workflow-early](https://pipedream.com/docs/code/nodejs#ending-a-workflow-early))\\n- [Use your connected accounts to make authenticated HTTP requests]([https://pipedream.com/docs/code/python/auth](https://pipedream.com/docs/code/nodejs/auth))\\n- [Reference environment variables]([https://pipedream.com/docs/code/python#using-secrets-in-code](https://pipedream.com/docs/code/nodejs#using-secrets-in-code))\\n- [Retrieve or update data within Data Stores]([https://pipedream.com/docs/code/python/using-data-stores](https://pipedream.com/docs/code/nodejs/using-data-stores))\\n- [Download, upload and manipulate files]([https://pipedream.com/docs/code/python/working-with-files](https://pipedream.com/docs/code/nodejs/working-with-files))\\n- [Pausing, resuming and rerunning Python code steps]([https://pipedream.com/docs/code/python/rerun](https://pipedream.com/docs/code/nodejs/rerun))\\n\\n# Troubleshooting\\n\\nPipedream will show your error traces within your individual steps, under the **Logs** section.\\n\\nTraces across all of your workflows are also available within the [Event History](https://pipedream.com/docs/event-history) in your Pipedream workspace. This gives a global view of all failed executions, and gives you the tools to filter by workflow, time occurred and more.\\n\",\"__typename\":\"MarketplaceContent\"}}}","hasNext":false}}
with HTML to Image and Python?
Create an image from HTML. See the documentation
Write Python and use any of the 350k+ PyPi packages available. Refer to the Pipedream Python docs to learn more.
Create a PDF file from HTML. See the documentation
Capture a screenshot from a URL. See the documentation
Create a PDF from a URL. See the documentation
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
html_to_image: {
type: "app",
app: "html_to_image",
}
},
async run({steps, $}) {
const data = {
"html_content" : "<div class=\"mt-4 p-4 text-center\"style=width:500px><span class=\"mb-4 tweet-text\">This is Little Bear. He tolerates baths because he knows how phenomenal his floof will appear afterwards. 13/10</span><div class=\"mt-2 p-4\"><img class=\"mt-4 border rounded-circle shadow\"src=https://docs.htmlcsstoimage.com/assets/images/dog.jpg width=100px></div><h4 class=mt-2>WeRateDogs</h4><span class=text-muted>@dog_rates</span></div><link href=https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css rel=stylesheet crossorigin=anonymous integrity=sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk><link href=\"https://fonts.googleapis.com/css2?family=Roboto:wght@700\"rel=stylesheet>",
"css_content" : ".tweet-text{background-color:#fff2ac;background-image:linear-gradient(to right,#ffe359 0,#fff2ac 100%);font-weight:bolder;font-size:32px;font-family:Roboto,sans-serif;padding:4px}",
"generate_img_url": true
}
return await axios($, {
method: "post",
url: `https://api.htmlcsstoimg.com/api/v1/generateImage`,
headers: {
"CLIENT-API-KEY": `${this.html_to_image.$auth.api_key}`,
},
data,
})
},
})
Develop, run and deploy your Python code in Pipedream workflows. Integrate seamlessly between no-code steps, with connected accounts, or integrate Data Stores and manipulate files within a workflow
This includes installing PyPI packages, within your code without having to manage a requirements.txt file or running pip.
Below is an example of using Python to access data from the trigger of the workflow, and sharing it with subsequent workflow steps:
def handler(pd: "pipedream"):
# Reference data from previous steps
print(pd.steps["trigger"]["context"]["id"])
# Return data for use in future steps
return {"foo": {"test":True}}