diff --git a/appengine/flexible/README.md b/appengine/flexible/README.md index 66e494ffaf4..db498e5f0bb 100644 --- a/appengine/flexible/README.md +++ b/appengine/flexible/README.md @@ -7,6 +7,9 @@ These are samples for using Python on Google App Engine Flexible Environment. These samples are typically referenced from the [docs](https://cloud.google.com/appengine/docs). +For code samples of Python version 3.7 and earlier, please check +https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/appengine/flexible. + See our other [Google Cloud Platform github repos](https://github.com/GoogleCloudPlatform) for sample applications and scaffolding for other frameworks and use cases. @@ -31,12 +34,9 @@ In general, the samples typically require: cd python-docs-samples/appengine/flexible ``` -4. Open a sample folder, create a virtualenv, install dependencies, and run the sample: +4. Follow https://cloud.google.com/python/docs/setup to set up a Python development environment. Then run: ``` - cd hello-world - virtualenv env - source env/bin/activate pip install -r requirements.txt python main.py ``` @@ -66,8 +66,8 @@ Some samples in this repositories may have special deployment instructions. Refe ## Contributing changes -* See [CONTRIBUTING.md](../CONTRIBUTING.md) +* See [CONTRIBUTING.md](../../CONTRIBUTING.md) ## Licensing -* See [LICENSE](../LICENSE) +* See [LICENSE](../../LICENSE) diff --git a/appengine/flexible/hello_world/app.yaml b/appengine/flexible/hello_world/app.yaml index 7aa7a47e159..ac38af83425 100644 --- a/appengine/flexible/hello_world/app.yaml +++ b/appengine/flexible/hello_world/app.yaml @@ -17,9 +17,9 @@ env: flex entrypoint: gunicorn -b :$PORT main:app runtime_config: - python_version: 3 + operating_system: ubuntu22 -# This sample incurs costs to run on the App Engine flexible environment. +# This sample incurs costs to run on the App Engine flexible environment. # The settings below are to reduce costs during testing and are not appropriate # for production use. For more information, see: # https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml diff --git a/appengine/flexible/hello_world/main.py b/appengine/flexible/hello_world/main.py index 8a5a5a9f6fc..ebbd393ef54 100644 --- a/appengine/flexible/hello_world/main.py +++ b/appengine/flexible/hello_world/main.py @@ -1,4 +1,4 @@ -# Copyright 2015 Google LLC. +# Copyright 2015 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ @app.route('/') -def hello(): +def hello() -> str: """Return a friendly HTTP greeting.""" return 'Hello World!' diff --git a/appengine/flexible/hello_world/main_test.py b/appengine/flexible/hello_world/main_test.py index 8bdbf76a920..341059c348d 100644 --- a/appengine/flexible/hello_world/main_test.py +++ b/appengine/flexible/hello_world/main_test.py @@ -1,4 +1,4 @@ -# Copyright 2015 Google LLC. +# Copyright 2015 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ import main -def test_index(): +def test_index() -> str: main.app.testing = True client = main.app.test_client() diff --git a/appengine/flexible_ubuntu/hello_world/noxfile_config.py b/appengine/flexible/hello_world/noxfile_config.py similarity index 100% rename from appengine/flexible_ubuntu/hello_world/noxfile_config.py rename to appengine/flexible/hello_world/noxfile_config.py diff --git a/appengine/flexible/hello_world/requirements-test.txt b/appengine/flexible/hello_world/requirements-test.txt index c2845bffbe8..95ea1e6a02b 100644 --- a/appengine/flexible/hello_world/requirements-test.txt +++ b/appengine/flexible/hello_world/requirements-test.txt @@ -1 +1 @@ -pytest==7.0.1 +pytest==6.2.4 diff --git a/appengine/flexible/hello_world/requirements.txt b/appengine/flexible/hello_world/requirements.txt index beeed7bed09..b690bf61e0a 100644 --- a/appengine/flexible/hello_world/requirements.txt +++ b/appengine/flexible/hello_world/requirements.txt @@ -1,3 +1,2 @@ -Flask==2.1.0; python_version > '3.6' -Flask==2.0.3; python_version < '3.7' +Flask==2.1.1 gunicorn==20.1.0 diff --git a/appengine/flexible/pubsub/README.md b/appengine/flexible/pubsub/README.md index c4c65500681..47707840594 100644 --- a/appengine/flexible/pubsub/README.md +++ b/appengine/flexible/pubsub/README.md @@ -32,10 +32,9 @@ When running locally, you can use the [Google Cloud SDK](https://cloud.google.co $ gcloud init -Install dependencies, preferably with a virtualenv: +Install dependencies, please follow https://cloud.google.com/python/docs/setup +to set up a Python development environment. Then run: - $ virtualenv env - $ source env/bin/activate $ pip install -r requirements.txt Then set environment variables before starting your application: diff --git a/appengine/flexible/pubsub/app.yaml b/appengine/flexible/pubsub/app.yaml index 5804ac2b266..95175b76687 100644 --- a/appengine/flexible/pubsub/app.yaml +++ b/appengine/flexible/pubsub/app.yaml @@ -17,7 +17,7 @@ env: flex entrypoint: gunicorn -b :$PORT main:app runtime_config: - python_version: 3 + operating_system: "ubuntu22" # [START gae_flex_pubsub_env] env_variables: diff --git a/appengine/flexible/static_files/app.yaml b/appengine/flexible/static_files/app.yaml index ca76f83fc3b..3605c19a7cb 100644 --- a/appengine/flexible/static_files/app.yaml +++ b/appengine/flexible/static_files/app.yaml @@ -17,4 +17,4 @@ env: flex entrypoint: gunicorn -b :$PORT main:app runtime_config: - python_version: 3 + operating_system: "ubuntu22" diff --git a/appengine/flexible/storage/app.yaml b/appengine/flexible/storage/app.yaml index e21a4c0ae91..fdfb9e7e3d1 100644 --- a/appengine/flexible/storage/app.yaml +++ b/appengine/flexible/storage/app.yaml @@ -17,9 +17,9 @@ env: flex entrypoint: gunicorn -b :$PORT main:app runtime_config: - python_version: 3 + operating_system: "ubuntu22" #[START gae_flex_storage_yaml] env_variables: - CLOUD_STORAGE_BUCKET: your-bucket-name + CLOUD_STORAGE_BUCKET: [your-bucket-name] #[END gae_flex_storage_yaml] diff --git a/appengine/flexible/storage/main.py b/appengine/flexible/storage/main.py index 6a20d7c05c5..98a363a6c3c 100644 --- a/appengine/flexible/storage/main.py +++ b/appengine/flexible/storage/main.py @@ -1,4 +1,4 @@ -# Copyright 2015 Google LLC. +# Copyright 2015 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,10 +23,10 @@ app = Flask(__name__) # Configure this environment variable via app.yaml -CLOUD_STORAGE_BUCKET = os.environ['CLOUD_STORAGE_BUCKET'] +CLOUD_STORAGE_BUCKET = os.environ["CLOUD_STORAGE_BUCKET"] -@app.route('/') +@app.route("/") def index() -> str: return """