Skip to main content

Emulator for Google Cloud Functions to run in local

Project description

Google Cloud Functions Python Emulator

downloads build

This module tries to emulate the environment in Google Cloud Functions for Python. It serves the given function on the given module.

For example. lets imagine we have the following cloud function

# mycloudfunction.py
def api(request):
  return 'important data'

To emulate we have to call it like so:

$ gcpfemu <path/to/file.py> <function_name>

For example, with the code above we will call it:

$ gcpfemu mycloudfunction.py api

And to access the data we can use for example curl:

$ curl localhost:5000/api
important data

If you want to run the emulator programatically you can do drun the server from a terminal, you have to disable the debug. It is disabled by default thoug. Flask looks for file changes, but in interactive terminal there's no file.

from gcpfemu import http 
port = 1234 # use a different port
module_path = 'mycloudfunction.py' # set the path to the code itself
function_name = 'api' # set the function name
http(module_path, function_name, port, debug) # load and serve the function

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcp-functions-emulator-0.1.1.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

gcp_functions_emulator-0.1.1-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page