I\'m trying out the Python3.7 runtime on Google Cloud Functions. I am able to deploy the functions and make them work once deployed, however, I can\'t seem to run the emulator t
You can use the Functions Framework for Python to run the function locally.
Given a function in a file named main.py
like so:
def my_function(request):
return 'Hello World'
You can do:
$ pip install functions-framework
$ functions-framework --target my_function
Which will start a local development server at http://localhost:8080.
To invoke it locally for an HTTP function:
$ curl http://localhost:8080
For a background function with non-binary data:
$ curl -d '{"data": {"hi": "there"}}' -X POST \
-H "Content-Type: application/json" \
http://localhost:8080
For a background function with binary data:
$ curl -d "@binary_file.file" -X POST \
-H "Ce-Type: true" \
-H "Ce-Specversion: true" \
-H "Ce-Source: true" \
-H "Ce-Id: true" \
-H "Content-Type: application/json" \
http://localhost:8080