ref: https://cloud.google.com/sdk/docs/quickstart-macos
- Download https://cloud.google.com/sdk/docs/ ( It will be downloaded to ~Downloads )
- unzip downloaded SDK:: tar -xvzf google-cloud-sdk-*.tar.gz
- ./google-cloud-sdk/install.sh
- ./google-cloud-sdk/bin/gcloud init
- PATH will be updated. In order to apply updated path, source ~/.bash_profile
ref: https://cloud.google.com/sdk/docs/components
$ gcloud components list
$ gcloud components install app-engine-python
$ gcloud components remove app-engine-python
gcloud projects create [YOUR_PROJECT_NAME] --set-as-default
gcloud projects describe [YOUR_PROJECT_NAME]
ref: https://cloud.google.com/appengine/docs/standard/python/quickstart
cd /home/web
git clone https://github.com/GoogleCloudPlatform/python-docs-samples
cd python-docs-samples/appengine/standard/hello_world
dev_appserver.py app.yaml
# open browser with http://localhost:8080/
## --- Deploying
gcloud app deploy
gcloud app browse
main.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
app.yaml
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
ref: https://cloud.google.com/appengine/docs/standard/python/quickstart
cd /home/web
git clone https://github.com/Gatsby-Lee/gcp-appengine-helloworld
cd gcp-appengine-helloworld/flask_standard
dev_appserver.py app.yaml
# open browser with http://localhost:8080/
## --- Deploying
gcloud app deploy
gcloud app browse
main.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Flask - GoogleAppEngine(GAE) Standard'
if __name__ == '__main__':
app.run(debug=True)
app.yaml
runtime: python37
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app