diff --git a/README.md b/README.md index d5fada6..9782b97 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,59 @@ -# hw6 template - -1. Fork a repository for yourself with the github "Fork" button. -2. Clone your repository to your local machine. -3. Start a local AppEngine server with `dev_appserver.py go/` or `dev_appserver.py python/` (depending on whether you're using Go or Python). -4. Add functionality and test your App by viewing the local instance at http://localhost:8080 -5. Deploy your app to AppEngine with `gcloud app deploy go/` or `gcloud app deploy python/` - 1. Note: the first time you do this, you'll have to first set up an AppEngine project via [Google Cloud Console](https://console.cloud.google.com/appengine/). -6. `git add .` and `git commit` and `git push` to upload your changes to your GitHub repository. -7. Send email to the STEP mailing list to show everyone your awesome App! - -Feel free to repeat steps 3-7 as much as you like! +# Homework 6 Template + +## Getting started + +1. Fork a repository for yourself with the github `Fork` button. + +1. Clone your repository to your local machine. + +1. If command line utility `gcloud` is not available, download and install + [Google Cloud SDK](https://cloud.google.com/sdk/docs/quickstarts) (Japanese + guides evailable). + + - Then install App Engine components for the programming language of your + choice. + - Go: `gcloud components install app-engine-go` + - Python: `gcloud components install app-engine-python + app-engine-python-extras` + - Run `gcloud init` to initialize the SDK and create a new Cloud Platform + project. This newly created Cloud Platform project will allow you to try + many Google Cloud Platform products, but we will only use Google App + Engine for this homework. + - If you already have Google Cloud SDK installed, run `gcloud components + update` to update to the latest version. + +1. Start a local App Engine server with `dev_appserver.py go/` or + `dev_appserver.py python-flask/` (depending on whether you're using Go or + Python). + +1. Add functionality and test your app by viewing the local instance at + http://localhost:8080. + +1. Deploy your app to App Engine with `gcloud app deploy go/` or `gcloud app + deploy python-flask/`. + + - The first time you deploy an App Engine app to your Cloud Platform + project, you will be asked to select a region for the location of your + App Engine app. Select `asia-northeast1` (Tokyo), `asia-northeast2` + (Osaka) or + [a region](https://cloud.google.com/compute/docs/regions-zones/) that is + close to you. + - Use `--version` flag to specify a version string manually, e.g. `gcloud + app deploy python-flask/ --version=python-flask-20190612`. + +1. Test your app in production by accessing the target url shown in the command + line console. To access a specific app version, use + `https://{VERSION}-dot-{PROJECT_NAME}.appspot.com`, e.g. + https://python-flask-20190612-dot-my-project-name.appspot.com. + +1. To stream production server logs in the command prompt console, run `gcloud + app logs tail -s default`. You can also use + [the web console](https://console.cloud.google.com/logs/viewer) to + view/stream server logs for debugging and troubleshooting. + +1. `git add .` and `git commit` and `git push` to upload your changes to your + GitHub repository. + +1. Send email to the STEP mailing list to show everyone your awesome app! + +Feel free to repeat steps 4-10 as much as you like! diff --git a/python-flask/.gcloudignore b/python-flask/.gcloudignore new file mode 100644 index 0000000..a987f11 --- /dev/null +++ b/python-flask/.gcloudignore @@ -0,0 +1,19 @@ +# This file specifies files that are *not* uploaded to Google Cloud Platform +# using gcloud. It follows the same syntax as .gitignore, with the addition of +# "#!include" directives (which insert the entries of the given .gitignore-style +# file at that point). +# +# For more information, run: +# $ gcloud topic gcloudignore +# +.gcloudignore +# If you would like to upload your .git directory, .gitignore file or files +# from your .gitignore file, remove the corresponding line +# below: +.git +.gitignore + +# Python pycache: +__pycache__/ +# Ignored by the build system +/setup.cfg \ No newline at end of file diff --git a/python-flask/app.yaml b/python-flask/app.yaml index ed8d253..ac4c378 100644 --- a/python-flask/app.yaml +++ b/python-flask/app.yaml @@ -1,7 +1,2 @@ -api_version: 1 -threadsafe: true -runtime: python27 +runtime: python37 -handlers: -- url: /.* - script: main.app diff --git a/python-flask/main.py b/python-flask/main.py index 2474878..62f0f0f 100644 --- a/python-flask/main.py +++ b/python-flask/main.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 from flask import Flask, render_template, request @@ -7,5 +6,5 @@ @app.route('/') def root(): - return render_template("hello.html") + return render_template('hello.html') diff --git a/python-flask/main_test.py b/python-flask/main_test.py index f4bd23b..7d694a4 100644 --- a/python-flask/main_test.py +++ b/python-flask/main_test.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 import main import webtest