This sample demonstrates how to render a template form from Google Storage using Cloud Functions.
Form Template See file functions/gcf-form-template/main.py for the code. The dependencies are listed in functions/gcf-form-template/requirements.txt.
The functions triggers on http request.
This sample comes with a Function and web-based UI for testing the function. To configure it:
- Create a Google Cloud Project using the Console GCP
- Create billing account Console Billing
- Enable the Cloud Functions API Console Cloud Functions
- Enable the Cloud Storage API Console Cloud Storage
To test the sample:
- Download and install gcloud command line tool Console
- From function path functions/gcf-render-template/ execute:
export FUNCTION_NAME="gcf-form-template";
export PATH_FILE="gcf-form-template.html";
export BUCKET_NAME="gcf-static-files";
gcloud beta functions deploy ${FUNCTION_NAME} --entry-point execute --set-env-vars BUCKET_NAME=${BUCKET_NAME},PATH_FILE=${PATH_FILE} --memory 128MB --runtime python37 --trigger-http;
- Return something like that:
Deploying function (may take a while - up to 2 minutes)...done.
availableMemoryMb: 128
entryPoint: execute
httpsTrigger:
url: https://[region]-[project id].cloudfunctions.net/gcf-form-template
labels:
deployment-tool: cli-gcloud
name: projects/[project id]/locations/[region]/functions/gcf-form-template
runtime: python37
serviceAccountEmail: [service account email]
status: ACTIVE
timeout: 60s
updateTime: '2018-11-22T16:05:07Z'
versionId: '1'