forked from alfonsof/google-cloud-python-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
20 lines (16 loc) · 601 Bytes
/
main.py
File metadata and controls
20 lines (16 loc) · 601 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python
# -*- coding: utf-8 -*-
# main.py
# It handles a Google Cloud Function that sends information about a Cloud Pub/Sub event that depends on the input to the function log.
def pubsub_event(event, context):
"""Triggered from a message on a Cloud Pub/Sub topic.
Args:
event (dict): Event payload.
context (google.cloud.functions.Context): Metadata for the event.
"""
import base64
if 'data' in event:
name = base64.b64decode(event['data']).decode('utf-8')
else:
name = 'World'
print('Hello {}!'.format(name))