Imagine you want to get updates from a service as soon as something changes. Why would a webhook push notifications instead of you asking repeatedly (polling)?
Think about how often you want to check your mailbox versus being told when mail arrives.
Webhooks push notifications to save resources and provide real-time updates. Polling requires repeated requests, which can waste bandwidth and delay updates.
Consider this Python code simulating a webhook notification system. What will it print?
def webhook_notify(event): if event == 'update': return 'Notification sent' else: return 'No notification' print(webhook_notify('update'))
Look at the event value passed to the function.
The function returns 'Notification sent' only if the event is 'update'. Since 'update' is passed, it prints that.
Look at this JavaScript code snippet meant to send webhook notifications. Why does it fail?
async function sendWebhook(data) { fetch('https://example.com/webhook', { method: 'POST', body: JSON.stringify(data), }); } sendWebhook({ event: 'update' });
Check what the server expects in the request headers.
Without 'Content-Type: application/json' header, the server may reject the JSON body, causing the webhook to fail.
Choose the correct Python function syntax to handle webhook POST requests.
Remember Python requires colons after if and else statements and uses '==' for comparison.
Option A uses correct syntax with colons and comparison operator '=='. Others have missing colons or wrong operators.
A webhook is set to notify on 'create' and 'delete' events. The system processes these events in order: ['create', 'update', 'delete', 'create', 'delete']. How many notifications will be sent?
Count only events that match 'create' or 'delete'.
Only 'create' and 'delete' events trigger notifications. The list ['create', 'update', 'delete', 'create', 'delete'] has four such events: two 'create' and two 'delete'.