This example shows how to serve a Serverless API composed of many functions through our serverless gateway.
This example uses:
- Python API Framework to deploy the functions.
- Serverless Gateway to deploy a serverless gateway container.
In order to test your functions locally before deployment in serverless functions, you can install our python offline testing library with:
pip install -r requirements-dev.txt
Launch your functions locally:
python app.py
Test your local functions using curl
:
curl localhost:8080/func_a
curl localhost:8080/func_b
curl localhost:8080/func_c
Deploy the serverless gateway as a container following the Serverless Gateway project instructions.
Make sure to export your gateway base URL (GATEWAY_HOST
) and an authentication token (TOKEN
)
Deploy your functions and add them automatically as endpoints to your serverless gateway using:
pip install -r requirements.txt
scw-serverless deploy app.py --gateway-url https://${GATEWAY_HOST} --gateway-api-key ${TOKEN}
You can use:
./scripts/list_gateway_endpoints.sh
You can use:
curl https://${GATEWAY_HOST}/<chosen_relative_path>
You can use:
./scripts/delete_function_to_gateway.sh https://<function_domain_name> /<chosen_relative_path>