Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.

Commit 3902dcd

Browse files
author
chenyumic
authored
Added samples for App Engine standard Python 3.7 runtime (GoogleCloudPlatform#1615)
1 parent 9d6540f commit 3902dcd

File tree

37 files changed

+930
-2
lines changed

37 files changed

+930
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file specifies files that are *not* uploaded to Google Cloud Platform
2+
# using gcloud. It follows the same syntax as .gitignore, with the addition of
3+
# "#!include" directives (which insert the entries of the given .gitignore-style
4+
# file at that point).
5+
#
6+
# For more information, run:
7+
# $ gcloud topic gcloudignore
8+
#
9+
.gcloudignore
10+
# If you would like to upload your .git directory, .gitignore file or files
11+
# from your .gitignore file, remove the corresponding line
12+
# below:
13+
.git
14+
.gitignore
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
runtime: python37
2+
3+
handlers:
4+
# This configures Google App Engine to serve the files in the app's static
5+
# directory.
6+
- url: /static
7+
static_dir: static
8+
9+
# This handler routes all requests not caught above to your main app. It is
10+
# required when static routes are defined, but can be omitted (along with
11+
# the entire handlers section) when there are no static files defined.
12+
- url: /.*
13+
script: auto
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2018 Google LLC
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 gae_python37_render_template]
16+
import datetime
17+
18+
from flask import Flask, render_template
19+
20+
app = Flask(__name__)
21+
22+
23+
@app.route('/')
24+
def root():
25+
# For the sake of example, use static information to inflate the template.
26+
# This will be replaced with real information in later steps.
27+
dummy_times = [datetime.datetime(2018, 1, 1, 10, 0, 0),
28+
datetime.datetime(2018, 1, 2, 10, 30, 0),
29+
datetime.datetime(2018, 1, 3, 11, 0, 0),
30+
]
31+
32+
return render_template('index.html', times=dummy_times)
33+
34+
35+
if __name__ == '__main__':
36+
# This is used when running locally only. When deploying to Google App
37+
# Engine, a webserver process such as Gunicorn will serve the app. This
38+
# can be configured by adding an `entrypoint` to app.yaml.
39+
# Flask's development server will automatically serve static files in
40+
# the "static" directory. See:
41+
# http://flask.pocoo.org/docs/1.0/quickstart/#static-files. Once deployed,
42+
# App Engine itself will serve those files as configured in app.yaml.
43+
app.run(host='127.0.0.1', port=8080, debug=True)
44+
# [START gae_python37_render_template]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
import main
16+
17+
18+
def test_index():
19+
main.app.testing = True
20+
client = main.app.test_client()
21+
22+
r = client.get('/')
23+
assert r.status_code == 200
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Flask==1.0.2
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright 2018, Google LLC
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+
16+
// [START gae_python37_log]
17+
'use strict';
18+
19+
window.addEventListener('load', function () {
20+
21+
console.log("Hello World!");
22+
23+
});
24+
// [END gae_python37_log]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
body {
2+
font-family: "helvetica", sans-serif;
3+
text-align: center;
4+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>Datastore and Firebase Auth Example</title>
5+
<script src="{{ url_for('static', filename='script.js') }}"></script>
6+
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
7+
</head>
8+
<body>
9+
10+
<h1>Datastore and Firebase Auth Example</h1>
11+
12+
<h2>Last 10 visits</h2>
13+
{% for time in times %}
14+
<p>{{ time }}</p>
15+
{% endfor %}
16+
17+
</body>
18+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file specifies files that are *not* uploaded to Google Cloud Platform
2+
# using gcloud. It follows the same syntax as .gitignore, with the addition of
3+
# "#!include" directives (which insert the entries of the given .gitignore-style
4+
# file at that point).
5+
#
6+
# For more information, run:
7+
# $ gcloud topic gcloudignore
8+
#
9+
.gcloudignore
10+
# If you would like to upload your .git directory, .gitignore file or files
11+
# from your .gitignore file, remove the corresponding line
12+
# below:
13+
.git
14+
.gitignore
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
runtime: python37
2+
3+
handlers:
4+
# This configures Google App Engine to serve the files in the app's static
5+
# directory.
6+
- url: /static
7+
static_dir: static
8+
9+
# This handler routes all requests not caught above to your main app. It is
10+
# required when static routes are defined, but can be omitted (along with
11+
# the entire handlers section) when there are no static files defined.
12+
- url: /.*
13+
script: auto

0 commit comments

Comments
 (0)