Comments (4)
Indeed, it's missing documentation on how to call a function when the type is not http
.
It's quite straightforward though. After some experiments, with a payload that looks like (for a function of type event
):
{
"eventId": "test",
"timestamp": "2018-04-09T07:56:12.975Z",
"eventType": "google.pubsub.topic.publish",
"resource": "my-app",
"data": {
"data": "dGhpcyBpcyBkYXRhIG5vb2I=",
"attributes": {
"app": "my-app",
"version": "1.0.0"
}
}
}
it returns
{'data': 'dGhpcyBpcyBkYXRhIG5vb2I=', 'attributes': {'app': 'my-app', 'version': '1.0.0'}}
{event_id: test, timestamp: 2018-04-09T07:56:12.975Z, event_type: google.pubsub.topic.publish, resource: my-app}
by doing simply print(event)
and print(context)
with a function runned with:
functions-framework --target=<name_of_function_to_run> --signature-type=event
Please note that I may have found mismatch with the documentation here.
For example, you have to pass eventId
and not event_id
for the param to be correctly passed.
Hope this helps and available for PR if needed 😃
from functions-framework-python.
Thanks for the issue. There are some examples in #23 but ultimately this is blocked on that issue -- the "correct" way would be with the emulator.
from functions-framework-python.
You're welcome, thanks for pointing me there, I'm leaving a quick example here for people stumbling upon the issue
If you are running:
functions-framework --signature-type=event
This is the way to send an event to the server:
$ curl -d '{"data": {"hi": "there"}}' -X POST -H "Content-Type: application/json" http://localhost:8080
from functions-framework-python.
Perhaps linking to https://cloud.google.com/functions/docs/running/calling#background_functions would be useful?
from functions-framework-python.
Related Issues (20)
- Firebase Functions Support HOT 1
- Possibility for multiple target/signature-type pairs?
- Gunicorn 21 is out HOT 3
- Flask Celery worker raise RuntimeError(unbound_message) from None RuntimeError: Working outside of request context. HOT 2
- Add Flask 3 support HOT 2
- README.md - Flask "Request" object hyperlink is broken HOT 2
- Native support for Pydantic models for function_framework.typed
- Document functions_framework.typed
- Support for postponed annnotations
- Improve developer experience for uncaught exceptions on GCP HOT 1
- PyPi development status alpha and other classifiers HOT 1
- functions-framework and tuning gunicorn HOT 1
- enhance framework to support pull subscriptions in addition to push subscriptions with pubsub
- Memory leaks? HOT 2
- ModuleNotFoundError: No module named 'urllib3.packages.six.moves'
- Bug: Firestore AggregationQuery stuck when running locally in Docker HOT 2
- Update type check in `get_user_function` to accept Callable instead of only types.FunctionType
- Blackduck scan showing HIGH level vulnerability on v3.5.0 HOT 1
- Sudden increase in memory usage from 3.5.0 to 3.6.0 HOT 10
- Version 3.8.0 breaks logging HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from functions-framework-python.