示例#1
0
def home():
    bukets = osclient.get_buckets()
    print(bukets)
    return render_template(
        "index.html",
        buckets=bukets,
        msg="Hello, the response from the server will be displayed here!")
示例#2
0
def delete_bucket():
    """Delete bucket
    Delete a bucket to Cloud Object Storage
    ---
    responses:
      200:
        description: A successful reply. Returns home page html.
    """
    bucketname = request.args.get("bucketname")
    print("deleting bucket: " + bucketname)
    resp = osclient.delete_bucket(bucketname)
    bukets = osclient.get_buckets()
    return render_template("index.html", buckets=bukets, msg=resp)
def create_bucket():
    """Create bucket
    Create a bucket in Cloud Object Storage
    ---
    responses:
      200:
        description: A successful reply. Returns home page html.
   """
    bucketname = request.args.get("bucketname")
    print("creating bucket: " + bucketname)
    resp = osclient.create_bucket(bucketname)
    bukets = osclient.get_buckets()
    return bukets
示例#4
0
def list_contents():
    """List bucket contents
    List bucket contents in Cloud Object Storage
    ---
    responses:
      200:
        description: A successful reply. Returns home page html with bucket contents.
   """
    bucketname = request.args.get("bucketname")
    bukets = osclient.get_buckets()
    files = osclient.get_files(bucketname)
    resp = "Contents of bucket " + bucketname + ":"
    for file in files:
        resp = resp + " " + file.key + ", "
    return render_template("index.html", buckets=bukets, msg=resp)
示例#5
0
def delete_object():
    """Delete file
    Delete a file from Cloud Object Storage
    ---
    responses:
      200:
        description: A successful reply. Returns home page html.
    """
    if request.method == 'GET':
        print(request.args)
        bucket = request.args["buket"]
        name = request.args["filename"]
        resp = osclient.delete_item(bucket, name)
        bukets = osclient.get_buckets()
        return render_template("index.html", buckets=bukets, msg=resp)
示例#6
0
def upload_file():
    """Upload file
    Upload a file to Cloud Object Storage
    ---
    responses:
      200:
        description: A successful reply. Returns home page html.
    """
    if request.method == 'POST':
        f = request.files['file']
        print(request.form)
        bucket = request.form["buket"]
        # save to object storage
        resp = osclient.put_file(bucket, f.filename, f.read())
        bukets = osclient.get_buckets()
        return render_template("index.html", buckets=bukets, msg=resp)