File tree Expand file tree Collapse file tree 11 files changed +118
-0
lines changed
Expand file tree Collapse file tree 11 files changed +118
-0
lines changed Original file line number Diff line number Diff line change 1+ lib
Original file line number Diff line number Diff line change 1+ ## Google App Engine Managed VMs Python Hello World
2+
3+ This sample demonstrates using [ Python on Google App Engine Managed VMs] ( https://cloud.google.com/appengine/docs/python/managed-vms/hello-world )
4+
5+ ### Running & deploying the sample
6+
7+ 1 . Requirements.txt is not automatically processed by Google App Engine Managed VMs. To install dependencies for this sample, run:
8+
9+ $ pip install -t lib -r requirements.txt
10+
11+ 2 . Run the sample on your development server:
12+
13+ $ dev_appserver.py .
14+
15+ 3 . Deploy the sample:
16+
17+ $ appcfg.py update -A your-app-id .
Original file line number Diff line number Diff line change 1+ version : 1
2+ runtime : python27
3+ vm : true
4+ api_version : 1
5+ threadsafe : true
6+
7+ handlers :
8+ - url : .* # This regex directs all routes to main.app
9+ script : main.app
Original file line number Diff line number Diff line change 1+ from google .appengine .ext import vendor
2+
3+ # Add any libraries installed in the "lib" folder.
4+ vendor .add ('lib' )
Original file line number Diff line number Diff line change 1+ # Copyright 2015 Google Inc. All Rights Reserved.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ # [START app]
16+ from flask import Flask
17+
18+
19+ app = Flask (__name__ )
20+
21+
22+ @app .route ('/' )
23+ def hello ():
24+ """Return a friendly HTTP greeting."""
25+ return 'Hello World!'
26+ # [END app]
Original file line number Diff line number Diff line change 1+ Flask == 0.10.1
Original file line number Diff line number Diff line change 1+ FROM google/python-runtime
2+
3+ ENTRYPOINT /env/bin/gunicorn -b 0.0.0.0:8080 main:app
Original file line number Diff line number Diff line change 1+ ## Google App Engine Managed VMs Python Custom Runtime Hello World
2+
3+ This sample demonstrates using [ Python on Google App Engine Managed VMs] ( https://cloud.google.com/appengine/docs/python/managed-vms/hello-world ) with a custom runtime.
4+
5+ This sample does not use the standard App Engine python runtime, but instead uses
6+ a custom runtime. The custom runtime ensures that any requirements defined
7+ in ` requirements.txt ` are automatically installed.
8+
9+ ### Running & deploying the sample
10+
11+ To run the sample locally, use a virtualenv:
12+
13+ $ virtualenv env
14+ $ source env/bin/activate.sh
15+ $ pip install -r requirements.txt
16+ $ python main.py
17+
18+ To deploy the sample, use the [ Google Cloud SDK] ( https://cloud.google.com/sdk )
19+
20+ $ gcloud preview app deploy app.yaml
Original file line number Diff line number Diff line change 1+ runtime : custom
2+ vm : true
3+ api_version : 1
Original file line number Diff line number Diff line change 1+ # Copyright 2015 Google Inc. All Rights Reserved.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ # [START app]
16+ from flask import Flask
17+
18+
19+ app = Flask (__name__ )
20+
21+
22+ @app .route ('/' )
23+ def hello ():
24+ """Return a friendly HTTP greeting."""
25+ return 'Hello World!'
26+
27+
28+ if __name__ == '__main__' :
29+ # This is used when running locally. Gunicorn is used to run the
30+ # application on Google App Engine. See ENTRYPOINT in the Dockerfile.
31+ app .run (host = '127.0.0.1' , port = 8080 , debug = True )
32+ # [END app]
You can’t perform that action at this time.
0 commit comments