This Python Code Outputs its Data to Airtable

This code is a simple program that prompts the user to enter two numbers, calculates the sum of those two numbers, and then sends the numbers and the sum to Airtable using a webhook.

The requests module is used to make an HTTP POST request to the webhook URL, with the numbers and sum as a JSON payload in the request body. The response variable holds the server’s response to the request.

The program then checks the status code of the response to determine if the request was successful. If the status code is 200, it means the request was successful and the numbers and sum were successfully sent to Airtable. If the status code is not 200, it means that the request failed, and the program prints a message indicating that it failed to send the numbers and sum to Airtable.

import requests

# Replace YOUR_WEBHOOK_URL with the actual webhook URL from Airtable
webhook_url = "YOUR_WEBHOOK_URL"

# Prompt the user for the first number
number_1 = int(input("Enter the first number: "))

# Prompt the user for the second number
number_2 = int(input("Enter the second number: "))

# Calculate the sum of the two numbers
sum = number_1 + number_2

# Send the two numbers and the sum to Airtable using the webhook
response = requests.post(webhook_url, json={"number_1": number_1, "number_2": number_2, "sum": sum})

# Check the status code of the response to see if the request was successful
if response.status_code == 200:
  print("Successfully sent numbers and sum to Airtable")
else:
  print("Failed to send numbers and sum to Airtable")

 

Leave the first comment