Testing Cloud Run locally via Function Framework
Functions Framework for Python
An open source FaaS (Function as a service) framework for writing portable Python functions -- brought to you by the Google Cloud Functions team.
The Functions Framework lets you write lightweight functions that run in many different environments, including:
- Google Cloud Functions
- Your local development machine
- Cloud Run and Cloud Run for Anthos
- Knative-based environments
Quickstart: Hello, World on your local machine
def hello(request):
return "Hello world!"
Quickstart: Build a Deployable Container
-
Build a container from your function using the Functions buildpacks:
bash sbin/build.sh
-
Start the built container:
bash sbin/run.sh # Output: Serving function...
-
Send requests to this function using
curl
from another terminal window:curl localhost:8080 # Output: Hello World!