Running a simple Python application with App Engine Flex 

To try this Python example in the App Engine Flex environment, for the context of this tutorial, it would be convenient to use Cloud Shell.:

  1. Once you have git installed, clone the following directory:
git clone https://github.com/GoogleCloudPlatform/python-docs-samples 
  1. Now, Python sample codes can be found in the following sub-directory:
cd python-docs-samples/appengine/flexible/hello_world  
  1. Now, run the application with the following:
python main.py
  1. You can also view the output on your browser's localhost:
http://localhost:8080 
  1. From this directory, we can run Python code. But before that, if you don't have virtual environment installed, do it with the following command:
sudo pip install virtualenv  
  1. In this virtual environment, create a dedicated Python environment along with its dependencies:
virtualenv env
source env/bin/activate
pip install -r requirements.txt
  1. Now, we can deploy this app by running the following command in the hello world directory:
gcloud app deploy
  1. Of course, the gcloud command only works if you have Google Cloud SDK installed on your local machine. We can view the deployed app's result with the following command. It will open a browser window and the address bar will contain an address having an http//PROJECT_ID.appspot.com pattern:
gcloud app browse
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.163.10