def upload_video()

in video/main.py [0:0]


def upload_video():
    # Create a Cloud Storage client.
    storage_client = storage.Client()

    # Get the Cloud Storage bucket that the file will be uploaded to.
    bucket = storage_client.get_bucket(os.environ.get('CLOUD_STORAGE_BUCKET'))

    # Create a new blob and upload the file's content to Cloud Storage.
    video = request.files['file']
    blob = bucket.blob(video.filename)
    blob.upload_from_string(
            video.read(), content_type=video.content_type)

    # Make the blob publicly viewable.
    blob.make_public()
    video_public_url = blob.public_url

    # Retrieve a Video response for the video stored in Cloud Storage
    source_uri = 'gs://{}/{}'.format(os.environ.get('CLOUD_STORAGE_BUCKET'), blob.name)
    label_annotations = get_label_annotations(source_uri)
    
    # Redirect to the home page.
    return render_template('homepage.html', video_public_url=video_public_url, video_content_type=video.content_type, label_annotations=label_annotations)