【问题标题】:Why Google Cloud Storage quickstart.py works on google cloud shell but not on Google App Engine?为什么 Google Cloud Storage quickstart.py 可以在 google cloud shell 上运行,但不能在 Google App Engine 上运行?
【发布时间】:2017-12-21 06:52:48
【问题描述】:

Google Cloud Storage quickstart.py 适用于 Google Cloud Shell,但不适用于 Google App Engine

快速入门.py

def run_quickstart():
    # [START storage_quickstart]
    # Imports the Google Cloud client library
    from google.cloud import storage
    # Instantiates a client
    storage_client = storage.Client()
    bucket_name = 'mygoolgeappproject.appspot.com'
    bucket = storage_client.get_bucket(bucket_name)
    blobs = bucket.list_blobs()`enter code here`
    for blob in blobs:
        print(blob.name)
    # The name for the new bucket
    #bucket_name = 'mygoolgeappproject.appspot.com'
    # Creates the new bucket
    #bucket = storage_client.create_bucket(bucket_name)
    #print('Bucket {} created.'.format(bucket.name))
    # [END storage_quickstart]

if __name__ == '__main__':
    run_quickstart()

【问题讨论】:

    标签: python-2.7 google-app-engine google-cloud-storage


    【解决方案1】:

    您不能将像 quickstart.py 这样的纯 Python 脚本直接作为 GAE 应用程序运行。用于不同目的的不同工具。

    您需要一个基本的 GAE 应用程序框架。您可以在Hello World code review 中找到示例骨架。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-27
      • 1970-01-01
      • 2015-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-17
      相关资源
      最近更新 更多