Skip to content

Commit 4f6ffd1

Browse files
chore(gae): delete region tags from standard/migration/urlfetch and remove Python 2 refs (#13092)
* chore(gae): add support for Python 3 to requirements-test.txt * docs(gae): delete region tags from standard/migration/urlfetch/async/main.py * chore(gae): add support for Python 3 to requirements-test.txt * docs(gae): delete region tags from standard/migration/urlfetch/requests/main.py * docs(gae): update README.md files to a current Python 3 sample, and remove Python 2 references
1 parent ea307c0 commit 4f6ffd1

File tree

6 files changed

+12
-33
lines changed

6 files changed

+12
-33
lines changed

appengine/standard/migration/urlfetch/async/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## App Engine async urlfetch Replacement
22

3-
The runtime for App Engine standard for Python 2.7 includes the `urlfetch`
3+
The runtime for App Engine standard for Python 3 includes the `urlfetch`
44
library, which is used to make HTTP(S) requests. There are several related
55
capabilities provided by that library:
66

@@ -10,13 +10,7 @@ capabilities provided by that library:
1010

1111
The sample in this directory provides a way to make asynchronous web requests
1212
using only generally available Python libraries that work in either App Engine
13-
standard for Python runtime, version 2.7 or 3.7. The sample code is the same
14-
for each environment.
15-
16-
To deploy and run this sample in App Engine standard for Python 2.7:
17-
18-
pip install -t lib -r requirements.txt
19-
gcloud app deploy
13+
standard for Python runtime, version 3.7.
2014

2115
To deploy and run this sample in App Engine standard for Python 3.7:
2216

appengine/standard/migration/urlfetch/async/main.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,20 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# [START app]
1615
import logging
1716
from time import sleep
1817

1918
from flask import Flask
2019
from flask import make_response
21-
# [START imports]
2220
from requests_futures.sessions import FuturesSession
2321

24-
# [END imports]
25-
2622

2723
TIMEOUT = 10 # Wait this many seconds for background calls to finish
2824
app = Flask(__name__)
2925

3026

3127
@app.route("/") # Fetch and return remote page asynchronously
3228
def get_async():
33-
# [START requests_get]
3429
session = FuturesSession()
3530
url = "http://www.google.com/humans.txt"
3631

@@ -41,7 +36,6 @@ def get_async():
4136
resp = make_response(rpc.result().text)
4237
resp.headers["Content-type"] = "text/plain"
4338
return resp
44-
# [END requests_get]
4539

4640

4741
@app.route("/callback") # Fetch and return remote pages using callback
@@ -103,6 +97,3 @@ def server_error(e):
10397
),
10498
500,
10599
)
106-
107-
108-
# [END app]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# pin pytest to 4.6.11 for Python2.
22
pytest==4.6.11; python_version < '3.0'
3+
4+
# pytest==8.3.4 and six==1.17.0 for Python3.
5+
pytest==8.3.4; python_version >= '3.0'
6+
six==1.17.0

appengine/standard/migration/urlfetch/requests/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## App Engine simple urlfetch Replacement
22

3-
The runtime for App Engine standard for Python 2.7 includes the `urlfetch`
3+
The runtime for App Engine standard for Python 3 includes the `urlfetch`
44
library, which is used to make HTTP(S) requests. There are several related
55
capabilities provided by that library:
66

@@ -10,13 +10,7 @@ capabilities provided by that library:
1010

1111
The sample in this directory provides a way to make straightforward web requests
1212
using only generally available Python libraries that work in either App Engine
13-
standard for Python runtime, version 2.7 or 3.7. The sample code is the same
14-
for each environment.
15-
16-
To deploy and run this sample in App Engine standard for Python 2.7:
17-
18-
pip install -t lib -r requirements.txt
19-
gcloud app deploy
13+
standard for Python runtime, version 3.7.
2014

2115
To deploy and run this sample in App Engine standard for Python 3.7:
2216

appengine/standard/migration/urlfetch/requests/main.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# [START app]
1615
import logging
1716

1817
from flask import Flask
1918

20-
# [START imports]
2119
import requests
2220

23-
# [END imports]
2421

2522
app = Flask(__name__)
2623

2724

2825
@app.route("/")
2926
def index():
30-
# [START requests_get]
3127
url = "http://www.google.com/humans.txt"
3228
response = requests.get(url)
3329
response.raise_for_status()
3430
return response.text
35-
# [END requests_get]
3631

3732

3833
@app.errorhandler(500)
@@ -49,9 +44,6 @@ def server_error(e):
4944
)
5045

5146

52-
# [END app]
53-
54-
5547
if __name__ == "__main__":
5648
# This is used when running locally.
5749
app.run(host="127.0.0.1", port=8080, debug=True)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# pin pytest to 4.6.11 for Python2.
22
pytest==4.6.11; python_version < '3.0'
3+
4+
# pytest==8.3.4 and six==1.17.0 for Python3.
5+
pytest==8.3.4; python_version >= '3.0'
6+
six==1.17.0

0 commit comments

Comments
 (0)