python3如何通过python列出GCP AppEngine中的存储桶?

问题描述 投票:0回答:2

我是python的新手,甚至是GCP Google Cloud App Engine的新手。我正在测试此脚本以列出我的存储桶,但是该脚本没有任何输出,甚至没有错误,并且当我将存储桶名称更改为不存在的名称时,我得到的结果相同,因此很奇怪。我正在使用本地操作系统linux。

~/pit$ python main.py 
(env) ~/pit$ 

这里是脚本>从Google https://cloud.google.com/storage/docs/listing-objects#storage-list-objects-python复制而来>>

main.py>

from google.cloud import storage


def list_blobs(bucket_name):
    """Lists all the blobs in the bucket."""
    bucket_name = "pyton_test_bucket"

    storage_client = storage.Client()

    # Note: Client.list_blobs requires at least package version 1.17.0.
    blobs = storage_client.list_blobs(bucket_name)

    for blob in blobs:
        print(blob.name)

[另一个问题是如何对我的测试瓶渲染索引模板实施此list命令?我的目标是在此之后的下一行中呈现列表对象h1>My Fav show is {{ show }}</在烧瓶示例中,仅显示了如何呈现1值,因此我不知道如何在这里进行Flask操作。

main.py

app = Flask(__name__)


@app.route('/')

def hello():
    tv_show="Test"
    return render_template("index.html", show=tv_show)


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.
    app.run(host='127.0.0.1', port=8080, debug=True)
# [END gae_python37_app]

index.html>

<!doctype html>
<html>
<head>
  <title>Test</title>
</head>
<body>

        <h1>My Fav show is {{ show }}</h1>


</body>
</html>

我是python的新手,甚至是GCP Google Cloud App Engine的新手。我正在测试此脚本以列出我的存储桶,但是当我更改时,脚本也没​​有输出,甚至没有错误,也响应...

python-3.x google-app-engine-python
2个回答
0
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.