Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 491a9f5

Browse filesBrowse files
author
Jon Wayne Parrott
committed
Adding a sample for extending the compat runtime.
1 parent b094eae commit 491a9f5
Copy full SHA for 491a9f5

File tree

Expand file treeCollapse file tree

9 files changed

+104
-3
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+104
-3
lines changed
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.dockerignore
2+
Dockerfile
3+
.git
4+
.hg
5+
.svn
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Extend the Managed VMs python-compat runtime.
2+
FROM gcr.io/google_appengine/python-compat-multicore
3+
4+
# Install the fortunes binary from the debian repositories.
5+
RUN apt-get update && apt-get install -y fortunes
6+
7+
ADD . /app/
8+
9+
RUN if [ -s requirements.txt ]; then pip install -r requirements.txt; fi
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Google App Engine Managed VMs extending runtime python-compat
2+
3+
This sample demonstrates how to extend the [python-compat](https://cloud.google.com/appengine/docs/managed-vms/python/migrating-an-existing-app) runtime 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 automatically installed by the runtime when deploying, however, to run the sample locally you will need to install dependencies:
8+
9+
$ pip install -r requirements.txt
10+
11+
2. Run the sample on your development server:
12+
13+
$ dev_appserver.py --runtime python-compat .
14+
15+
3. Deploy the sample:
16+
17+
$ gcloud preview app deploy
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
runtime: custom
2+
vm: true
3+
threadsafe: true
4+
api_version: 1
5+
6+
handlers:
7+
- url: .* # This regex directs all routes to main.app
8+
script: main.app
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2016 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+
import subprocess
17+
18+
from flask import Flask
19+
20+
21+
app = Flask(__name__)
22+
23+
24+
# [START example]
25+
@app.route('/')
26+
def fortune():
27+
output = subprocess.check_output('/usr/games/fortune')
28+
return output, 200, {'Content-Type': 'text/plain; charset=utf-8'}
29+
# [END example]
30+
# [END app]
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2016 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+
import os
16+
17+
import main
18+
import pytest
19+
20+
21+
@pytest.mark.skipif(
22+
not os.path.exists('/usr/games/fortune'),
23+
reason='Fortune executable is not installed.')
24+
def test_index():
25+
main.app.testing = True
26+
client = main.app.test_client()
27+
28+
r = client.get('/')
29+
assert r.status_code == 200
30+
assert len(r.data)
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Flask==0.10.1

‎managed_vms/hello_world_compat/README.md

Copy file name to clipboardExpand all lines: managed_vms/hello_world_compat/README.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
## Google App Engine Managed VMs Python Hello World
1+
## Google App Engine Managed VMs python-compat Hello World
22

3-
This sample demonstrates using [Python on Google App Engine Managed VMs](https://cloud.google.com/appengine/docs/python/managed-vms/hello-world)
3+
This sample demonstrates using the [python-compat](https://cloud.google.com/appengine/docs/managed-vms/python/migrating-an-existing-app) runtime on [Google App Engine Managed VMs](https://cloud.google.com/appengine/docs/python/managed-vms/hello-world)
44

55
### Running & deploying the sample
66

77
1. `requirements.txt` is automatically installed by the runtime when deploying, however, to run the sample locally you will need to install dependencies:
88

9-
$ pip install -t lib -r requirements.txt
9+
$ pip install -r requirements.txt
1010

1111
2. Run the sample on your development server:
1212

‎managed_vms/hello_world_compat/app.yaml

Copy file name to clipboardExpand all lines: managed_vms/hello_world_compat/app.yaml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
runtime: python-compat
22
vm: true
33
threadsafe: true
4+
api_version: 1
45

56
handlers:
67
- url: .* # This regex directs all routes to main.app

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.