Skip to main content

An API framework to make it easy to work with Scaleway Serverless functions.

Project description

Serverless API Framework

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 scw-serverless:

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.

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.

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

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

scw_serverless-0.0.2.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

scw_serverless-0.0.2-py3-none-any.whl (11.3 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