Framework for writing serverless APIs in Python, using Scaleway functions and containers.
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 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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for scw_serverless-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81846494877ad04582a81fa2d0970d7f76d1221c9b1411a9b049e1af36deb01a |
|
MD5 | 70d12134be5ed9fd286c21906078d05b |
|
BLAKE2b-256 | 1b5938b8662b18f15ffcd42a0f285e78fc88d47f8a4f87553b058c6a2d36e73b |