run gcp functions locally (python)
run a single function export GCLOUD_PROJECT="XXX" export GOOGLE_ACCOUNT="your@email.com" echo "GOOGLE_ACCOUNT=$GOOGLE_ACCOUNT" export GOOGLE_APPLICATION_CREDENTIALS=$HOME/.config/gcloud/legacy_credentials/${GOOGLE_ACCOUNT}/adc.json export YOUR_ENV_VAR="foo" pip3 install functions-framework functions-framework --source ./path/to/yuor/main.py --target your_python_function_name --debug run a custom api functions/run_functions_locally.py from flask import Flask, request from my_function_a.main import my_python_function_a from my_function_b.main import my_python_function_b app = Flask(__name__) @app.route('/') def index(): return 'Index Page' @app.get('/api/a') def get_a(): return my_python_function_a(request) @app.post('/api/b') def post_b(): return my_python_function_b(request) functions/my_python_function_a/main.py import functions_framework YOUR_ENV_VAR = os.getenv("YOUR_ENV_VAR") @functions_framework.http def my_python_function_b(request): headers = { 'Access-Control-Allow-Origin': '*', } return "hello from function a YOUR_ENV_VAR=" + YOUR_ENV_VAR, 200, headers functions/my_python_function_b/main....