As you know I used the default sample app engine hello word standard application.
The goal is to understand how it works by working with Google's documentation and examples.
Into this project folder we have this files:
08/17/2017 11:12 PM 98 app.yaml
08/17/2017 11:12 PM 854 main.py
08/17/2017 11:12 PM 817 main_test.py
Let's see what these files contain:First is app.yaml and come with:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
The next is main.py file:# Copyright 2016 Google Inc.
#
# 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.
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
The last from this folder is main_test.py :# Copyright 2016 Google Inc. All rights reserved.
#
# 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.
import webtest
import main
def test_get():
app = webtest.TestApp(main.app)
response = app.get('/')
assert response.status_int == 200
assert response.body == 'Hello, World!'
The app.yaml file is used to configure your App Engine application's settings of the project.You can have many application-level configuration files (dispatch.yaml, cron.yaml, index.yaml, and queue.yaml).
This all type of configuration files are included in the top level app directory ( in this case: hello_world).
Let's see some common gcloud commands:
- gcloud app deploy --project XXXXXX - deploy your project;
- gcloud app browse - show your project running into your browser;
- gcloud components list - show all available components;
- gcloud components update - update all gcloud components;
- gcloud projects list --limit=10 - show all projects with a limit number;
First, change the text from main.py file with something else:
self.response.write('Hello, World!')
Now use this commands:C:\Python27\python-docs-samples\appengine\standard\hello_world>gcloud app deploy
C:\Python27\python-docs-samples\appengine\standard\hello_world>gcloud app browse
The result is shown in your browser.You can read about this files into google documentation page - here.
Also some gcloud commands and reference you can read here.