Skip to main content

Serverless API Framework

PyPI version Documentation Status pre-commit.ci status

Serverless API Framework is a tool that lets you write and deploy serverless functions in Python. It bridges your code with the deployment configuration to make it a breeze to work with serverless functions.

Starts by defining a simple Python function:

from scw_serverless import Serverless

app = Serverless("hello-namespace")

@app.func(memory_limit=256)
def hello_world(event, context):
    return "Hello World!"

Deploy it with scw-serverless:

scw-serverless deploy app.py

Quickstart

Install

pip install scw-serverless

This will install the scw-serverless CLI:

scw-serverless --help

Writing and configuring functions

You can transform your Python functions into serverless functions by using decorators:

import os
import requests
from scw_serverless import Serverless

app = Serverless("hello-namespace")
API_URL = os.environ["API_URL"]

@app.func(memory_limit=256, env={"API_URL": API_URL})
def hello_world(event, context):
    return requests.get(API_URL)

The configuration is done by passing arguments to the decorator. To view which arguments are supported, head over to this documentation page.

Local testing

Before deploying, you can run your functions locally with the dev command:

scw-serverless dev app.py

This runs a local Flask server with your Serverless handlers. If no relative_url is defined for a function, it will be served on /name with name being the name of your Python function.

By default, this runs Flask in debug mode which includes hot-reloading. You can disable this behavior by passing the --no-debug flag.

Deploying

When you are ready, you can deploy your function with the scw-serverless CLI tool:

scw-serverless deploy app.py

The tool will use your Scaleway credentials from your environment and config file.

What’s Next?

To learn more about the framework, have a look at the documentation. If you want to see it in action, we provide some examples to get you started.

To run your Python functions locally, check out Scaleway Functions Python.

Contributing

We welcome all contributions.

This project uses pre-commit hooks to run code quality checks locally. We recommended installing them before contributing.

pre-commit install

Metadata

Release files for scw-serverless 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scw-serverless 1.2.0
File Size Uploaded
scw_serverless-1.2.0.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scw-serverless 1.2.0
File Interpreter ABI Platform
scw_serverless-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 41.9 kB

Release files / scw_serverless-1.2.0.tar.gz

Download URL scw_serverless-1.2.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a9e2274157833be7b93aad59ff06734cbe4f793ef508c1070940c4faee2a29cf
BLAKE2b-256 checksum
How to use checksums
28a5ac9e69fa569a1881e08c11ed26020be2463603d02a5ea3889757ca9c6516
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.4 Linux/5.18.0-0.deb11.4-cloud-amd64

Release files / scw_serverless-1.2.0-py3-none-any.whl

Download URL scw_serverless-1.2.0-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2bf5fa92b1f018d94ce5fd934b9b44969b471701a79659b2e6fc9bf356856b6
BLAKE2b-256 checksum
How to use checksums
6ae4d75fc488120a6b3e0de984bdf3a24a5600e42e2a9e3485d3c118d1f11365
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.4 Linux/5.18.0-0.deb11.4-cloud-amd64

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page