diff --git a/app.yaml b/app.yaml new file mode 100644 index 0000000..f8b1056 --- /dev/null +++ b/app.yaml @@ -0,0 +1,13 @@ +runtime: python37 + +handlers: + # This configures Google App Engine to serve the files in the app's static + # directory. +- url: /static + static_dir: static + + # This handler routes all requests not caught above to your main app. It is + # required when static routes are defined, but can be omitted (along with + # the entire handlers section) when there are no static files defined. +- url: /.* + script: auto diff --git a/main.py b/main.py new file mode 100644 index 0000000..e161f10 --- /dev/null +++ b/main.py @@ -0,0 +1,44 @@ +# Copyright 2018 Google LLC +# +# 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. + +# [START gae_python37_render_template] +import datetime + +from flask import Flask, render_template + +app = Flask(__name__) + + +@app.route('/') +def root(): + # For the sake of example, use static information to inflate the template. + # This will be replaced with real information in later steps. + dummy_times = [datetime.datetime(2018, 1, 1, 10, 0, 0), + datetime.datetime(2018, 1, 2, 10, 30, 0), + datetime.datetime(2018, 1, 3, 11, 0, 0), + ] + + return render_template('index.html', times=dummy_times) + + +if __name__ == '__main__': + # This is used when running locally only. When deploying to Google App + # Engine, a webserver process such as Gunicorn will serve the app. This + # can be configured by adding an `entrypoint` to app.yaml. + # Flask's development server will automatically serve static files in + # the "static" directory. See: + # http://flask.pocoo.org/docs/1.0/quickstart/#static-files. Once deployed, + # App Engine itself will serve those files as configured in app.yaml. + app.run(host='127.0.0.1', port=8080, debug=True) +# [START gae_python37_render_template] diff --git a/main_test.py b/main_test.py new file mode 100644 index 0000000..380ee88 --- /dev/null +++ b/main_test.py @@ -0,0 +1,23 @@ +# Copyright 2015 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 main + + +def test_index(): + main.app.testing = True + client = main.app.test_client() + + r = client.get('/') + assert r.status_code == 200 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f2e1e50 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Flask==1.0.2 diff --git a/static/script.js b/static/script.js new file mode 100644 index 0000000..4ec5e25 --- /dev/null +++ b/static/script.js @@ -0,0 +1,24 @@ +/** + * Copyright 2018, Google LLC + * 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. + */ + +// [START gae_python37_log] +'use strict'; + +window.addEventListener('load', function () { + + console.log("Hello World!"); + +}); +// [END gae_python37_log] diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..8401745 --- /dev/null +++ b/static/style.css @@ -0,0 +1,4 @@ +body { + font-family: "helvetica", sans-serif; + text-align: center; +} diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..f159e28 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,18 @@ + + +
+{{ time }}
+ {% endfor %} + + +