This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import storage | |
storage_client = storage.Client(project='your-project-id') | |
def list_blobs(bucket_name): | |
"""Lists all the blobs in the bucket""" | |
blobs = storage_client.list_blobs(bucket_name) | |
for blob in blobs: | |
print(blob.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import storage | |
storage_client = storage.Client(project='your-project-id') #add your ProjectID here | |
def delete_bucket(bucket_name): | |
"""Deletes a bucket. The bucket must be empty.""" | |
# bucket_name = "your-bucket-name" | |
storage_client = storage.Client() | |
bucket = storage_client.get_bucket(bucket_name) | |
bucket.delete() | |
print("Bucket {} deleted".format(bucket.name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import storage | |
storage_client = storage.Client(project='your-project-id') #add your ProjectID here | |
def create_bucket(dataset_name): | |
"""Creates a new bucket""" | |
print('function create_bucket called') | |
bucket = storage_client.create_bucket(dataset_name) | |
print('Bucket {} created'.format(bucket.name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upload_blob(bucket_name, source_data, destination_blob_name): | |
"""Uploads a file to the bucket.""" | |
print('function upload_blob called') | |
bucket = storage_client.get_bucket(bucket_name) | |
blob = bucket.blob(destination_blob_name) | |
blob.upload_from_string(source_data) | |
print('File {} uploaded to {}.'.format(destination_blob_name, bucket_name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import jsonify | |
from geopy.geocoders import Nominatim | |
import requests | |
from google.cloud import storage | |
import json | |
storage_client = storage.Client(project='your-project-id') #replace with your projectID from Home | |
def weather(request): | |
data = {"success": False} |