functions-framework
An open source FaaS (Function as a service) framework for writing portable Python functions -- brought to you by the Google Cloud Functions team.
Description
# Functions Framework for Python [](https://badge.fury.io/py/functions-framework) [![Python unit CI][ff_python_unit_img]][ff_python_unit_link] [![Python lint CI][ff_python_lint_img]][ff_python_lint_link] [![Python conformace CI][ff_python_conformance_img]][ff_python_conformance_link]  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 Run Functions](https://cloud.google.com/functions/) * Your local development machine * [Knative](https://github.com/knative/)-based environments The framework allows you to go from: ```python def hello(request): return "Hello world!" ``` To: ```sh curl http://my-url # Output: Hello world! ``` All without needing to worry about writing an HTTP server or complicated request handling logic. ## Features * Spin up a local development server for quick testing * Invoke a function in response to a request * Automatically unmarshal events conforming to the [CloudEvents](https://cloudevents.io/) spec * Portable between serverless platforms ## Installation Install the Functions Framework via `pip`: ```sh pip install functions-framework ``` Or, for deployment, add the Functions Framework to your `requirements.txt` file: ``` functions-framework==3.* ``` ## Quickstarts ### Quickstart: HTTP Function (Hello World) Create an `main.py` file with the following contents: ```python import flask import functions_framework @functions_framework.http def hello(request: flask.Request) -> flask.typing.ResponseReturnValue: return "Hello world!" ``` > Your function is passed a single parameter, `(request)`, which is a Flask [`Request`](https://flask.palletsprojects.com/en/3.0.x/api/#flask.Request) object. Run the following command: ```sh functions-framework --target hello --debug * Serving Flask app "hello" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit) ``` (You can also use `functions-framework-python` if you have multiple language frameworks installed). Open http://localhost:8080/ in your browser and see *Hello world!*. Or send requests to this function using `curl` from another terminal window: ```sh curl localhost:8080 # Output: Hello world! ``` ### Quickstart: CloudEvent Function Create an `main.py` file with the following contents: ```python import functions_framework from cloudevents.http.event import CloudEvent @functions_framework.cloud_event def hello_cloud_event(cloud_event: CloudEvent) -> None: print(f"Received event with ID: {cloud_event['id']} and data {cloud_event.data}") ``` > Your function is passed a single [CloudEvent](https://github.com/cloudevents/sdk-python/blob/main/cloudevents/sdk/event/v1.py) parameter. Run the following command to run `hello_cloud_event` target locally: ```sh functions-framework --target=hello_cloud_event ``` In a different terminal, `curl` the Functions Framework server: ```sh curl -X POST localhost:8080 \ -H "Content-Type: application/cloudevents+json" \ -d '{ "specversion" : "1.0", "type" : "example.com.cloud.event", "source" : "https://example.com/cloudevents/pull", "subject" : "123", "id" : "A234-1234-1234", "time" : "2018-04-05T17:31:00Z", "data" : "hello world" }' ``` Output from the terminal running `functions-framework`: ``` Received event with ID: A234-1234-1234 and data hello world ``` More info on sending [CloudEvents](http://cloudevents.io) payloads, see [`examples/cloud_run_cloud_events`](examples/cloud_run_cloud_events/) instruction. ### Quickstart: Error handling The framework includes an error handler that is similar to the [`flask.Flask.errorhandler`](https://flask.palletsprojects.com/en/1.1.x/api/#flask.Flask.errorhandler) function, which allows you to handle specific error types with a decorator: ```python import functions_framework @functions_framework.errorhandler(ZeroDivisionError) def handle_zero_division(e): return "I'm a teapot", 418 def function(request): 1 / 0 return "Success", 200 ``` This function will catch the `ZeroDivisionError` and return a different response instead. ### Quickstart: Pub/Sub emulator 1. Create a `main.py` file with the following contents: ```python def hello(event, context): print("Received", context.event_id) ``` 1. Start the Functions Framework on port 8080: ```sh functions-framework --target=hello --signature-type=event --debug --port=8080 ``` 1. In a second terminal, start the
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| 3.10.1 | Imported from PyPI (3.10.1) | Low | 4/21/2026 |
| v3.10.1 | ## [3.10.1](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.10.0...v3.10.1) (2026-02-17) ### Bug Fixes * Correct cloudevents dependency to allow 1.11.0 ([#405](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/405)) ([8d74a7b](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/8d74a7b9ecead58df77208d6e4717419a9aa9447)) * pin lint tool versions to avoid surprise breakages ([#413](https://github.com/GoogleCloudPlatform/fu | Low | 2/17/2026 |
| v3.10.0 | ## [3.10.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.9.2...v3.10.0) (2025-11-10) ### Features * Add async and streaming examples ([#393](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/393)) ([a07b1e4](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/a07b1e4f81d84424189488022e5f3d59c06014cc)) ### Bug Fixes * **ci:** Add release-assets.githubusercontent.com to allowed endpoints ([#394](https://github.com/Go | Low | 11/10/2025 |
| v3.9.2 | ## [3.9.2](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.9.1...v3.9.2) (2025-07-24) ### Bug Fixes * increase start delay for ASGI conformance tests to address flaky failures ([#391](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/391)) ([1b6c428](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/1b6c428d559991134240473f6622f8759a3360d5)) | Low | 7/28/2025 |
| v3.9.1 | ## [3.9.1](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.9.0...v3.9.1) (2025-07-24) ### Bug Fixes * remove unused httpx dependency ([#389](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/389)) ([26fb101](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/26fb101d556a39262855a304c1ac351856ce4b61)) | Low | 7/24/2025 |
| v3.9.0 | ## [3.9.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.8.3...v3.9.0) (2025-07-23) ### Features * add execution_id support for async stack ([#377](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/377)) ([1123eea](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/1123eeac8cedae23af8980a928f01f5ad100d9de)) * add flag to run functions framework in asgi stack ([#376](https://github.com/GoogleCloudPlatform/functions-fra | Low | 7/23/2025 |
| v3.8.3 | ## [3.8.3](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.8.2...v3.8.3) (2025-05-14) ### Bug Fixes * Switch to `pyproject.toml` based builds ([#365](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/365)) ([4c44d08](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/4c44d08c5ebb304e80a3adc3f8e6d150987b29bb)) * Update minimum required version of Flask to 2.0 ([#356](https://github.com/GoogleCloudPlatform/functions-frame | Low | 5/16/2025 |
| v3.8.2 | ## [3.8.2](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.8.1...v3.8.2) (2024-11-13) ### Bug Fixes * remove unused import ([#349](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/349)) ([d5ac3d8](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/d5ac3d8d01fdb71f7454a0433e586f1eb4a0f6fe)) | Low | 11/13/2024 |
| v3.8.1 | ## [3.8.1](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.8.0...v3.8.1) (2024-07-26) ### Bug Fixes * upgrade gunicorn to 22 to fix CVE-2024-1135 ([#341](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/341)) ([d622f13](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/d622f137e8a2419fc487c867d67e12d0204b586b)) | Low | 7/26/2024 |
| v3.8.0 | ## [3.8.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.7.0...v3.8.0) (2024-06-25) ### Features * Set default logging level to align with Flask's defaults ([#336](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/336)) ([d1d0753](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/d1d0753b6ea0dcc4222e28fc61002ac563b54cac)) ### Bug Fixes * add www.bestpractices.dev:443 to scorecard ([#330](https://github.com/GoogleC | Low | 6/26/2024 |
| v3.7.0 | ## [3.7.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.6.0...v3.7.0) (2024-05-17) ### Features * (opt-in): terminate handling of work when the request has already timed out ([#328](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/328)) ([2601975](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/2601975285386fc573de8033381edc99527ef3c9)) * Add execution id ([#320](https://github.com/GoogleCloudPlatform/functions-f | Low | 5/22/2024 |
| v3.6.0 | ## [3.6.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.5.0...v3.6.0) (2024-04-29) ### Features * avoid long running process when request timeout ([#309](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/309)) ([3a0cdb8](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/3a0cdb8ba1065510d8ca0f2bcabd484cd3ffaaf6)) | Low | 4/29/2024 |
| v3.5.0 | ## [3.5.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.4.0...v3.5.0) (2023-11-28) ### Features * initial typing of the public API ([#248](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/248)) ([45aed53](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/45aed538b5e39655318c7841457399fa3376ceaf)) ### Bug Fixes * don't exit on reload if there is a syntax error ([#214](https://github.com/GoogleCloudPlatform/functi | Low | 11/28/2023 |
| v3.4.0 | ## [3.4.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.3.0...v3.4.0) (2023-05-24) ### Features * configure security score card action ([#216](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/216)) ([7868dc1](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/7868dc110c048d3e1acf082faf36b75c3770e3f3)) ### Bug Fixes * streaming requests cannot access request data ([#245](https://github.com/GoogleCloudPlatform/func | Low | 5/25/2023 |
| v3.3.0 | ## [3.3.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.2.1...v3.3.0) (2022-12-16) ### Features * Support strongly typed functions signature ([#208](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/208)) ([aa59a6b](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/aa59a6b6839820946dc72ceea7fd97b3dfd839c2)) ### Bug Fixes * remove DRY_RUN env var and --dry-run flag ([#210](https://github.com/GoogleCloudPlatform/fu | Low | 12/21/2022 |
| v3.2.1 | ## [3.2.1](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.2.0...v3.2.1) (2022-11-09) ### Bug Fixes * Remove the 10MB limit ([#205](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/205)) ([34b8083](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/34b8083c53d88d378718916cc2c20de7665150d4)) | Low | 11/10/2022 |
| v3.2.0 | ## [3.2.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.1.0...v3.2.0) (2022-08-11) ### Features * Scale gunicorn server to serve 1000 concurrent requests ([#195](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/195)) ([91e2efa](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/91e2efa9356b120a07906023119219d99a6a0791)) | Low | 8/17/2022 |
| v3.1.0 | ## [3.1.0](https://github.com/GoogleCloudPlatform/functions-framework-python/compare/v3.0.0...v3.1.0) (2022-06-09) ### Features * Add more details to MissingTargetException error ([#189](https://github.com/GoogleCloudPlatform/functions-framework-python/issues/189)) ([b7055ed](https://github.com/GoogleCloudPlatform/functions-framework-python/commit/b7055ed838523cda71bf71bc0149f33271e60ebc)) * allow for watchdog>=2.0.0 ([#186](https://github.com/GoogleCloudPlatform/functions-framework-python/is | Low | 6/9/2022 |
| v3.0.0 | ### Changed - Change `cloudevent` declarative function signature to `cloud_event` (#167) | Low | 11/10/2021 |
| v2.4.0-beta.2 | ### Fixed - Remove debug statements | Low | 11/1/2021 |
| v2.4.0-beta.1 | ### Added - Support declarative function signatures: `http` and `cloudevent` | Low | 10/29/2021 |
| v2.3.0 | Release v2.3.0 | Low | 10/12/2021 |
| v2.2.1 | ### Changed - Update GCF Python 3.7 backwards-compatible logging (#131) | Low | 6/1/2021 |
| v2.2.0 | ### Added - Relax constraint to `flask<3.0` and `click<9.0` (#129) | Low | 5/24/2021 |
| v2.1.3 | ### Changed - Change gunicorn loglevel to error ([#122]) ### Added - Add support for background to CloudEvent conversion ([#116]) | Low | 4/23/2021 |
| v2.1.2 | ### Added - Add crash header to 500 responses (#114) | Low | 2/24/2021 |
| v2.1.1 | ### Fixed - Add backwards-compatible logging for GCF Python 3.7 (#107) - Document `--dry-run` flag (#105) | Low | 2/17/2021 |
| v2.1.0 | ### Added - Support Python 3.9 ### Fixed - Execute the source module w/in the app context (#76) | Low | 12/23/2020 |
| v1.6.0 | ### Changed - Add legacy GCF Python 3.7 behavior (#77) ### Added - Improve documentation around Dockerfiles (#70) | Low | 8/19/2020 |
| v1.5.0 | ### Changed - Framework will consume entire request before responding (#66) | Low | 7/6/2020 |
| v2.0.0 | ### Added - Support `cloudevent` signature type (#55, #56) ### Changed - Framework will consume entire request before responding (#66) | Low | 7/2/2020 |
| v1.4.4 | ### Fixed - Improve module loading (#61) | Low | 6/19/2020 |
| v1.4.3 | ### Fixed - Load the source file into the correct module name (#49) | Low | 5/14/2020 |
| v1.4.2 | ### Fixed * Fix handling of `--debug` flag when gunicorn is not present (#44) | Low | 5/13/2020 |
| v1.4.1 | ### Fixed * Windows support broken due to gunicorn (#38) | Low | 5/8/2020 |
| v1.4.0 | ### Added: * Added ability to `gunicorn` as a production HTTP server (#36) | Low | 5/6/2020 |
| v1.3.0 | ### Added: - Add support for running `python -m functions_framework` (#31) - Move `functions_framework.cli.cli` to `functions_framework._cli._cli` - Adjust path handling for robots.txt and favicon.ico (#33) | Low | 4/13/2020 |
| v1.2.0 | ### Added - Add support for `--host` flag (#20) | Low | 2/20/2020 |
| v1.1.1 | ### Added - Add support for `--dry-run` flag (#14) ### Changed - Make `--debug` a flag instead of a boolean option ### Fixed - Better support for CloudEvent functions and error handling | Low | 2/7/2020 |
| v1.0.1 | ### Added - Add Cloud Run Button (#1) - Add README badges (#2) - Add `debug` flag documentation (#7) - Add `watchdog` dependency (#8) ### Fixed - Fix `--signature-type` typo (#4) - Fix `install_requires` typo (#12) | Low | 1/30/2020 |
| v1.0.0 | Initial published version of Functions Framework for Python. | Low | 1/9/2020 |
