Registry / gcp / functions-framework

functions-framework

JSON →
library3.10.1pypypi✓ verified 35d ago

Functions Framework for Python is an open-source FaaS (Function as a Service) framework designed for writing portable Python functions. It allows developers to test their Google Cloud Functions locally, run them in other serverless environments, or deploy them directly to Google Cloud. The current version is 3.10.1, and it maintains an active release cadence with frequent patch and minor updates, typically every 1-3 months.

gcpweb-frameworkdevops
Install & Compatibility
Where this runs
tested against v3.10.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.930 runs
installs and imports cleanly · install 0.0s · import 0.480s · 30.4MB
glibc
py 3.103.930 runs
installs and imports cleanly · install 3.4s · import 0.437s · 31MB
29MB installed
● package 29MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

For HTTP functions, the primary input argument is a Flask Request object. No direct import of `functions_framework` is typically needed in your function code.

from flask import Request

For CloudEvent functions, the primary input argument is a CloudEvent object. No direct import of `functions_framework` is typically needed in your function code.

from cloudevents.http import CloudEvent

Define an HTTP function `hello_http` in a file (e.g., `main.py`). The function receives a `flask.Request` object. Run it locally using the `functions-framework` CLI, specifying the function name with `--target`. By default, it runs on port 8080.

# main.py def hello_http(request): """Responds to any HTTP request. Args: request (flask.Request): The request object. Returns: The response text, or any set of values that can be turned into a Response object using `make_response`. """ request_json = request.get_json(silent=True) request_args = request.args if request_json and 'name' in request_json: name = request_json['name'] elif request_args and 'name' in request_args: name = request_args['name'] else: name = 'World' return f'Hello {name}!' # To run locally: # 1. Save this as main.py # 2. Run from your terminal: functions-framework --target hello_http # 3. Access at http://localhost:8080/
functions-framework --version
Debug
Known footguns
breakingFunctions Framework v3.8.3 and later require Flask 2.0 or higher. If your project uses an older version of Flask, you may encounter `ImportError` or other compatibility issues.
gotchaWhen running locally, you must specify the target function using the `--target` flag (e.g., `functions-framework --target my_function`). Failing to do so will result in an error indicating no target was found.
gotchaEnsure your function signature matches the expected type (HTTP or CloudEvent). HTTP functions take a `flask.Request` object. CloudEvent functions take a `cloudevents.CloudEvent` object.
gotchaFor CloudEvents, access the event data via `event.data` for the actual payload. CloudEvents often wrap the original payload (e.g., Pub/Sub messages are nested).
breakingVersion 3.10.1 corrected the `cloudevents` dependency to allow `1.11.0`. Older `functions-framework` versions might have had improperly constrained `cloudevents` dependencies, potentially leading to issues if `cloudevents` was upgraded to an incompatible version.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
22 hits · last 30 days
claudebot
7
gptbot
4
ahrefsbot
4
dotbot
1
Resources