AppEngine - Python

tudent_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ sudo apt update
# Copyright 2018 Google LLC
Get:1 https://cli.github.com/packages stable InRelease [3,917 B]
Get:2 https://download.docker.com/linux/ubuntu noble InRelease [48.8 kB]                                                                                                                                                       
Get:3 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]                                                                                                                                                                  
Get:4 https://apt.postgresql.org/pub/repos/apt noble-pgdg InRelease [107 kB]                                                                                                                            
Hit:5 https://packages.cloud.google.com/apt gcsfuse-noble InRelease                                                                                                                                     
Get:6 https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 InRelease [3,005 B]                                                           
Get:7 https://cli.github.com/packages stable/main amd64 Packages [347 B]                                                
Hit:8 http://archive.ubuntu.com/ubuntu noble InRelease                                                                                                
Get:9 https://packages.cloud.google.com/apt cloud-sdk InRelease [1,620 B]                                                                                       
Get:10 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages [38.1 kB]                   
Get:11 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]                                            
Get:12 https://apt.postgresql.org/pub/repos/apt noble-pgdg/main amd64 Packages [562 kB]      
Get:13 https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0/multiverse amd64 Packages [51.3 kB]                     
Hit:14 https://ppa.launchpadcontent.net/dotnet/backports/ubuntu noble InRelease
Get:15 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
Get:16 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [2,478 kB]
Get:17 https://packages.cloud.google.com/apt cloud-sdk/main all Packages [1,839 kB]
Get:18 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1,924 kB]                  
Get:19 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [1,519 kB]                                
Get:20 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [1,138 kB]                         
Get:21 https://packages.cloud.google.com/apt cloud-sdk/main amd64 Packages [4,193 kB]                                   
Get:22 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [1,882 kB]          
Get:23 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Packages [2,612 kB]
Fetched 18.8 MB in 2s (7,744 kB/s)                           
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
32 packages can be upgraded. Run 'apt list --upgradable' to see them.
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ sudo apyt install -y python3-venv
sudo: apyt: command not found
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ sudo apt install -y python3-venv                                                                                
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-venv is already the newest version (3.12.3-0ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ python3 -m venv myenv
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ source myenv/bin/activate
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ flash --app main run
-bash: flash: command not found
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ flask --app main run                                                                                    
 * Serving Flask app 'main'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
127.0.0.1 - - [06/Oct/2025 19:15:42] "GET /?authuser=0 HTTP/1.1" 200 -
127.0.0.1 - - [06/Oct/2025 19:15:43] "GET /favicon.ico HTTP/1.1" 404 -
^C(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ vi main.py
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ flask --app main run
 * Serving Flask app 'main'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
127.0.0.1 - - [06/Oct/2025 19:16:58] "GET /?authuser=0 HTTP/1.1" 200 -
^C(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ ls -l
total 28
-rw-rw-r-- 1 student_04_347b5286260a student_04_347b5286260a  595 Oct  6 19:08 app.yaml
-rw-rw-r-- 1 student_04_347b5286260a student_04_347b5286260a 1316 Oct  6 19:16 main.py
-rw-rw-r-- 1 student_04_347b5286260a student_04_347b5286260a  780 Oct  6 19:08 main_test.py
drwxrwxr-x 5 student_04_347b5286260a student_04_347b5286260a 4096 Oct  6 19:14 myenv
drwxrwxr-x 2 student_04_347b5286260a student_04_347b5286260a 4096 Oct  6 19:16 __pycache__
-rw-rw-r-- 1 student_04_347b5286260a student_04_347b5286260a   14 Oct  6 19:08 requirements-test.txt
-rw-rw-r-- 1 student_04_347b5286260a student_04_347b5286260a   13 Oct  6 19:08 requirements.txt
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ cat app.yaml | grep -v "^#"

runtime: python312
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ cat main.py | grep -v "^#"a| grep .
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [START gae_python38_app]
# [START gae_python3_app]
from flask import Flask
# If `entrypoint` is not defined in app.yaml, App Engine will look for an app
# called `app` in `main.py`.
app = Flask(__name__)
@app.route("/")
def hello():
    """Return a friendly HTTP greeting.
    Returns:
        A string with the words 'Hello World!'.
    """
    return "Hello Ketan's World!"
if __name__ == "__main__":
    # This is used when running locally only. When deploying to Google App
    # Engine, a webserver process such as Gunicorn will serve the app. You
    # can configure startup instructions by adding `entrypoint` to app.yaml.
    app.run(host="127.0.0.1", port=8080, debug=True)
# [END gae_python3_app]
# [END gae_python38_app]
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ cat main.py | grep -v "^#" | grep .
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
    """Return a friendly HTTP greeting.
    Returns:
        A string with the words 'Hello World!'.
    """
    return "Hello Ketan's World!"
if __name__ == "__main__":
    # This is used when running locally only. When deploying to Google App
    # Engine, a webserver process such as Gunicorn will serve the app. You
    # can configure startup instructions by adding `entrypoint` to app.yaml.
    app.run(host="127.0.0.1", port=8080, debug=True)
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ gcloud app deploy
WARNING: You might be using automatic scaling for a standard environment deployment, without providing a value for automatic_scaling.max_instances. Starting from March, 2025, App Engine sets the automatic scaling maximum instances default for standard environment deployments to 20. This change doesn't impact existing apps. To override the default, specify the new max_instances value in your app.yaml file, and deploy a new version or redeploy over an existing version. For details on max_instances, see https://cloud.google.com/appengine/docs/standard/reference/app-yaml.md#scaling_elements. 

You are creating an app for project [qwiklabs-gcp-00-88834e0beca1].
WARNING: Creating an App Engine application for a project is irreversible and the region
cannot be changed. More information about regions is at
<https://cloud.google.com/appengine/docs/locations>.

WARNING: Starting from March, 2025, App Engine sets the automatic scaling maximum instances
default for standard environment deployments to 20. This change doesn't impact
existing apps. To override the default, specify the new max_instances value in your
app.yaml file, and deploy a new version or redeploy over an existing version.
For more details on max_instances, see
<https://cloud.google.com/appengine/docs/standard/reference/app-yaml.md#scaling_elements>.

NOTE: Cloud Run offers the most modern fully managed application hosting experience
with lower minimum billable times and support for GPUs on demand for your AI/ML workloads.
Deploy code written in any programming language supported by App Engine on Cloud Run.
Learn more at https://cloud.google.com/run/docs/quickstarts#build-and-deploy-a-web-service

Please choose the region where you want your App Engine application located:

 [1] europe-west   (supports standard and flexible and search_api)
 [2] us-central    (supports standard and flexible and search_api)
 [3] cancel
Please enter your numeric choice:  1

Creating App Engine application in project [qwiklabs-gcp-00-88834e0beca1] and region [europe-west]....done.                                                                                                                                      
Services to deploy:

descriptor:                  [/home/student_04_347b5286260a/python-docs-samples/appengine/standard_python3/hello_world/app.yaml]
source:                      [/home/student_04_347b5286260a/python-docs-samples/appengine/standard_python3/hello_world]
target project:              [qwiklabs-gcp-00-88834e0beca1]
target service:              [default]
target version:              [20251006t191900]
target url:                  [https://qwiklabs-gcp-00-88834e0beca1.ew.r.appspot.com]
target service account:      [qwiklabs-gcp-00-88834e0beca1@appspot.gserviceaccount.com]


Do you want to continue (Y/n)?  Y

Beginning deployment of service [default]...
Created .gcloudignore file. See `gcloud topic gcloudignore` for details.
Uploading 506 files to Google Cloud Storage
5%
10%
15%
21%
26%
31%
36%
41%
46%
51%
57%
62%
67%
72%
77%
82%
87%
92%
98%
100%
100%
File upload done.
Updating service [default]...done.                                                                                                                                                                                                               
Setting traffic split for service [default]...done.                                                                                                                                                                                              
Deployed service [default] to [https://qwiklabs-gcp-00-88834e0beca1.ew.r.appspot.com]

You can stream logs from the command line by running:
  $ gcloud app logs tail -s default

To view your application in the web browser run:
  $ gcloud app browse
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ gcloud app browse
Did not detect your browser. Go to this link to view your app:
https://qwiklabs-gcp-00-88834e0beca1.ew.r.appspot.com
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$



myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ history

    4  gcloud config set compute/region europe-west1
    6  gcloud config list
    7  git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
    8  cd python-docs-samples/appengine/standard_python3/hello_world/
   
   27  sudo apt update

   29  sudo apt install -y python3-venv
   30  python3 -m venv myenv
   31  source myenv/bin/activate
   33  flask --app main run

   35  flask --app main run
   40  gcloud app deploy
   41  gcloud app browse
   42  history
(myenv) student_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ 

No comments:

Post a Comment

AppEngine - Python

tudent_04_347b5286260a@cloudshell:~/python-docs-samples/appengine/standard_python3/hello_world (qwiklabs-gcp-00-88834e0beca1)$ sudo apt upda...