File tree Expand file tree Collapse file tree 6 files changed +12
-33
lines changed
appengine/standard/migration/urlfetch Expand file tree Collapse file tree 6 files changed +12
-33
lines changed Original file line number Diff line number Diff line change 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 `
44library, which is used to make HTTP(S) requests. There are several related
55capabilities provided by that library:
66
@@ -10,13 +10,7 @@ capabilities provided by that library:
1010
1111The sample in this directory provides a way to make asynchronous web requests
1212using 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
2115To deploy and run this sample in App Engine standard for Python 3.7:
2216
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- # [START app]
1615import logging
1716from time import sleep
1817
1918from flask import Flask
2019from flask import make_response
21- # [START imports]
2220from requests_futures .sessions import FuturesSession
2321
24- # [END imports]
25-
2622
2723TIMEOUT = 10 # Wait this many seconds for background calls to finish
2824app = Flask (__name__ )
2925
3026
3127@app .route ("/" ) # Fetch and return remote page asynchronously
3228def 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]
Original file line number Diff line number Diff line change 11# pin pytest to 4.6.11 for Python2.
22pytest==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
Original file line number Diff line number Diff line change 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 `
44library, which is used to make HTTP(S) requests. There are several related
55capabilities provided by that library:
66
@@ -10,13 +10,7 @@ capabilities provided by that library:
1010
1111The sample in this directory provides a way to make straightforward web requests
1212using 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
2115To deploy and run this sample in App Engine standard for Python 3.7:
2216
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- # [START app]
1615import logging
1716
1817from flask import Flask
1918
20- # [START imports]
2119import requests
2220
23- # [END imports]
2421
2522app = Flask (__name__ )
2623
2724
2825@app .route ("/" )
2926def 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-
5547if __name__ == "__main__" :
5648 # This is used when running locally.
5749 app .run (host = "127.0.0.1" , port = 8080 , debug = True )
Original file line number Diff line number Diff line change 11# pin pytest to 4.6.11 for Python2.
22pytest==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
You can’t perform that action at this time.
0 commit comments