12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- # [START app]
16
15
import base64
17
16
import json
18
17
import logging
39
38
CLAIMS = []
40
39
41
40
41
+ # [START gae_standard_pubsub_index]
42
42
# [START index]
43
43
@app .route ("/" , methods = ["GET" , "POST" ])
44
44
def index ():
@@ -58,9 +58,8 @@ def index():
58
58
future = publisher .publish (topic_path , data )
59
59
future .result ()
60
60
return "OK" , 200
61
-
62
-
63
61
# [END index]
62
+ # [END gae_standard_pubsub_index]
64
63
65
64
66
65
# [START gae_standard_pubsub_auth_push]
@@ -104,10 +103,9 @@ def receive_messages_handler():
104
103
MESSAGES .append (payload )
105
104
# Returning any 2xx status indicates successful receipt of the message.
106
105
return "OK" , 200
107
-
108
-
109
106
# [END gae_standard_pubsub_auth_push]
110
107
108
+
111
109
# [START gae_standard_pubsub_push]
112
110
@app .route ("/pubsub/push" , methods = ["POST" ])
113
111
def receive_pubsub_messages_handler ():
@@ -118,9 +116,9 @@ def receive_pubsub_messages_handler():
118
116
envelope = json .loads (request .data .decode ("utf-8" ))
119
117
payload = base64 .b64decode (envelope ["message" ]["data" ])
120
118
MESSAGES .append (payload )
119
+
121
120
# Returning any 2xx status indicates successful receipt of the message.
122
121
return "OK" , 200
123
-
124
122
# [END gae_standard_pubsub_push]
125
123
126
124
@@ -142,4 +140,3 @@ def server_error(e):
142
140
# This is used when running locally. Gunicorn is used to run the
143
141
# application on Google App Engine. See entrypoint in app.yaml.
144
142
app .run (host = "127.0.0.1" , port = 8080 , debug = True )
145
- # [END app]
0 commit comments