View Dockerfile
# Use the official lightweight Python image. | |
# https://hub.docker.com/_/python | |
FROM python:3.7-slim | |
# Copy local code to the container image. | |
ENV APP_HOME /app | |
WORKDIR $APP_HOME | |
COPY . ./ | |
# Install production dependencies. |
View deploy.sh
# !/bin/bash | |
# Set env var "GCP_PROJECT" to our project name | |
GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null) | |
# Set our Cloud Run region (so we aren't prompted) | |
gcloud config set run/region us-central1 | |
# Build and upload your image in Google Container Registry | |
gcloud builds submit --tag gcr.io/$GCP_PROJECT/yt | |
# Deploy your container to Cloud Run | |
ENV=$(cat .env) |
View app.py
import os | |
import argparse | |
from dotenv import load_dotenv | |
from flask import Flask, request | |
from googleapiclient.discovery import build | |
from googleapiclient.errors import HttpError | |
# Setup YouTube API | |
KEY = os.environ.get('KEY') | |
YOUTUBE_API_SERVICE_NAME = 'youtube' |
View main.go
package main | |
import ( | |
"log" | |
"os" | |
"example.com/hello" | |
"github.com/GoogleCloudPlatform/functions-framework-go/framework" | |
) |
View function.go
package hello | |
import ( | |
"net/http" | |
"fmt" | |
) | |
// HelloWorld writes "Hello, World!" to the HTTP response. | |
func HelloWorld(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprint(w, "Hello, World!\n") |
View index.js
const express = require('express'); | |
const app = express(); | |
const routes = { | |
'/foo': (req, res) => res.send('This is a test.'), | |
}; | |
Object.entries(routes).map(([route, func]) => app.use(route, func)); | |
app.use('/', (req, res) => res.send(Object.keys(routes))); // default | |
// Export the Express app to the Functions Framework | |
exports.function = app; |
View index.js
const parent = client.queuePath(project, location, queue); | |
const task = { | |
httpRequest: { | |
httpMethod: 'POST', | |
url, | |
}, | |
}; | |
const [response] = await client.createTask({parent, task}); |
View pizza.json
[ | |
{ | |
"formatted_address":"11 Park Pl, New York, NY 10007, United States", | |
"geometry":{ | |
"location":{ | |
"lat":40.7130634, | |
"lng":-74.0082771 | |
}, | |
"viewport":{ | |
"northeast":{ |
View cities.txt
Viti, Kosovo | |
Shtërpcë, Kosovo | |
Shtime, Kosovo | |
Vushtrri, Kosovo | |
Bonney Lake, United States | |
Spokane Valley, United States | |
Bellevue, United States | |
Marysville, United States | |
Newcastle, United States | |
North Bend, United States |
View cities.txt
Malishevë, Kosovo | |
Prizren, Kosovo | |
Zubin Potok, Kosovo | |
Kamenicë, Kosovo | |
Viti, Kosovo | |
Shtërpcë, Kosovo | |
Shtime, Kosovo | |
Vushtrri, Kosovo | |
Dragash, Kosovo | |
Podujevë, Kosovo |
NewerOlder