1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- # [START app]
1615import base64
1716import json
1817import logging
3938CLAIMS = []
4039
4140
41+ # [START gae_standard_pubsub_index]
4242# [START index]
4343@app .route ("/" , methods = ["GET" , "POST" ])
4444def index ():
@@ -58,9 +58,8 @@ def index():
5858 future = publisher .publish (topic_path , data )
5959 future .result ()
6060 return "OK" , 200
61-
62-
6361# [END index]
62+ # [END gae_standard_pubsub_index]
6463
6564
6665# [START gae_standard_pubsub_auth_push]
@@ -104,10 +103,9 @@ def receive_messages_handler():
104103 MESSAGES .append (payload )
105104 # Returning any 2xx status indicates successful receipt of the message.
106105 return "OK" , 200
107-
108-
109106# [END gae_standard_pubsub_auth_push]
110107
108+
111109# [START gae_standard_pubsub_push]
112110@app .route ("/pubsub/push" , methods = ["POST" ])
113111def receive_pubsub_messages_handler ():
@@ -118,9 +116,9 @@ def receive_pubsub_messages_handler():
118116 envelope = json .loads (request .data .decode ("utf-8" ))
119117 payload = base64 .b64decode (envelope ["message" ]["data" ])
120118 MESSAGES .append (payload )
119+
121120 # Returning any 2xx status indicates successful receipt of the message.
122121 return "OK" , 200
123-
124122# [END gae_standard_pubsub_push]
125123
126124
@@ -142,4 +140,3 @@ def server_error(e):
142140 # This is used when running locally. Gunicorn is used to run the
143141 # application on Google App Engine. See entrypoint in app.yaml.
144142 app .run (host = "127.0.0.1" , port = 8080 , debug = True )
145- # [END app]
0 commit comments