为什么谷歌云存储quickstart.py适用于谷歌云外壳而不适用于谷歌应用引擎?

时间:2017-07-16 18:59:45

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

Google云端存储quickstart.py适用于Google Cloud Shell但不适用于Google App Engine

quickstart.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()

1 个答案:

答案 0 :(得分:0)

您无法直接将quickstart.py这样的普通python脚本作为GAE应用运行。用于不同目的的不同工具。

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