You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This demonstrates how to send and receive messages using [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) on [Google App Engine Standard Environment](https://cloud.google.com/appengine/docs/standard/).
8
+
This demonstrates how to send and receive messages using [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) on [Google App Engine Standard Environment](https://cloud.google.com/appengine/docs/standard/) for
9
+
Python 2.7 or for Python 3. See instructions below for deploying in either
10
+
of those two environments.
9
11
10
12
## Setup
11
13
@@ -30,7 +32,7 @@ Before you can run or deploy the sample, you will need to do the following:
1. Update the environment variables in ``app.yaml``.
35
+
1. Update the environment variables in ``app.yaml`` for Python 3, or ``app27.yaml`` for Python 2.7.
34
36
35
37
## Running locally
36
38
@@ -78,8 +80,17 @@ The simulated push request fails because it does not have a Cloud Pub/Sub-genera
78
80
79
81
Note: Not all the files in the current directory are needed to run your code on App Engine. Specifically, `main_test.py` and the `data` directory, which contains a mocked private key file and a mocked public certs file, are for testing purposes only. They SHOULD NOT be included when deploying your app. When your app is up and running, Cloud Pub/Sub's push servers create tokens using a private key, then the Google Auth Python library takes care of verifying and decoding the token using Google's public certs, to confirm that the push requests indeed come from Cloud Pub/Sub.
80
82
81
-
In the current directory, deploy using `gcloud`:
83
+
In the current directory, deploy using `gcloud`. For Python 2.7 you must first
84
+
install the required libraries in the `lib` folder:
82
85
83
-
$ gcloud app deploy app.yaml
86
+
$ pip -t lib -r requirements.txt
87
+
$ gcloud app deploy app27.yaml
84
88
85
-
You can now access the application at `https://[your-app-id].appspot.com`. You can use the form to submit messages, but it's non-deterministic which instance of your application will receive the notification. You can send multiple messages and refresh the page to see the received message.
89
+
For Python 3, you can simply run the deploy command:
90
+
91
+
$ gcloud app deploy app27.yaml
92
+
93
+
You can now access the application using the `gcloud app browse` command. You
94
+
can use the form to submit messages, but it's non-deterministic which instance
95
+
of your application will receive the notification. You can send multiple
96
+
messages and refresh the page to see the received message.
0 commit comments