scw-serverless


Namescw-serverless JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/scaleway/serverless-api-framework-python
SummaryFramework for writing serverless APIs in Python, using Scaleway functions and containers.
upload_time2023-07-04 10:05:22
maintainer
docs_urlNone
authorScaleway Serverless Team
requires_python>=3.10,<3.12
licenseMIT
keywords serverless scaleway functions cloud faas
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Serverless API Framework

[![PyPI version](https://badge.fury.io/py/scw-serverless.svg)](https://badge.fury.io/py/scw-serverless)
[![Documentation Status](https://readthedocs.org/projects/serverless-api-project/badge/?version=latest)](https://serverless-api-project.readthedocs.io/en/latest/?badge=latest)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/scaleway/serverless-api-framework-python/main.svg)](https://results.pre-commit.ci/latest/github/scaleway/serverless-api-framework-python/main)

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:

```python
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`:

```console
scw-serverless deploy app.py
```

## Quickstart

### Install

```console
pip install scw-serverless
```

This will install the `scw-serverless` CLI:

```console
scw-serverless --help
```

### Writing and configuring functions

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

```python
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](https://serverless-api-framework-python.readthedocs.io/) page.

### Local testing

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

```console
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:

```console
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](https://serverless-api-project.readthedocs.io/).
If you want to see it in action, we provide some [examples](https://github.com/scaleway/serverless-api-framework-python-python/tree/main/examples) to get you started.

To run your Python functions locally, check out [Scaleway Functions Python](https://github.com/scaleway/serverless-functions-python).

## Contributing

We welcome all contributions.

This project uses [pre-commit](https://pre-commit.com/) hooks to run code quality checks locally. We recommended installing them before contributing.

```console
pre-commit install
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/scaleway/serverless-api-framework-python",
    "name": "scw-serverless",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<3.12",
    "maintainer_email": "",
    "keywords": "serverless,scaleway,functions,cloud,faas",
    "author": "Scaleway Serverless Team",
    "author_email": "opensource@scaleway.com",
    "download_url": "https://files.pythonhosted.org/packages/28/a5/ac9e69fa569a1881e08c11ed26020be2463603d02a5ea3889757ca9c6516/scw_serverless-1.2.0.tar.gz",
    "platform": null,
    "description": "# Serverless API Framework\n\n[![PyPI version](https://badge.fury.io/py/scw-serverless.svg)](https://badge.fury.io/py/scw-serverless)\n[![Documentation Status](https://readthedocs.org/projects/serverless-api-project/badge/?version=latest)](https://serverless-api-project.readthedocs.io/en/latest/?badge=latest)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/scaleway/serverless-api-framework-python/main.svg)](https://results.pre-commit.ci/latest/github/scaleway/serverless-api-framework-python/main)\n\nServerless API Framework is a tool that lets you write and deploy serverless functions in Python.\nIt bridges your code with the deployment configuration to make it a breeze to work with serverless functions.\n\nStarts by defining a simple Python function:\n\n```python\nfrom scw_serverless import Serverless\n\napp = Serverless(\"hello-namespace\")\n\n@app.func(memory_limit=256)\ndef hello_world(event, context):\n    return \"Hello World!\"\n```\n\nDeploy it with `scw-serverless`:\n\n```console\nscw-serverless deploy app.py\n```\n\n## Quickstart\n\n### Install\n\n```console\npip install scw-serverless\n```\n\nThis will install the `scw-serverless` CLI:\n\n```console\nscw-serverless --help\n```\n\n### Writing and configuring functions\n\nYou can transform your Python functions into serverless functions by using decorators:\n\n```python\nimport os\nimport requests\nfrom scw_serverless import Serverless\n\napp = Serverless(\"hello-namespace\")\nAPI_URL = os.environ[\"API_URL\"]\n\n@app.func(memory_limit=256, env={\"API_URL\": API_URL})\ndef hello_world(event, context):\n    return requests.get(API_URL)\n```\n\nThe configuration is done by passing arguments to the decorator.\nTo view which arguments are supported, head over to this [documentation](https://serverless-api-framework-python.readthedocs.io/) page.\n\n### Local testing\n\nBefore deploying, you can run your functions locally with the dev command:\n\n```console\nscw-serverless dev app.py\n```\n\nThis 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.\n\nBy default, this runs Flask in debug mode which includes hot-reloading. You can disable this behavior by passing the `--no-debug` flag.\n\n### Deploying\n\nWhen you are ready, you can deploy your function with the `scw-serverless` CLI tool:\n\n```console\nscw-serverless deploy app.py\n```\n\nThe tool will use your Scaleway credentials from your environment and config file.\n\n## What\u2019s Next?\n\nTo learn more about the framework, have a look at the [documentation](https://serverless-api-project.readthedocs.io/).\nIf you want to see it in action, we provide some [examples](https://github.com/scaleway/serverless-api-framework-python-python/tree/main/examples) to get you started.\n\nTo run your Python functions locally, check out [Scaleway Functions Python](https://github.com/scaleway/serverless-functions-python).\n\n## Contributing\n\nWe welcome all contributions.\n\nThis project uses [pre-commit](https://pre-commit.com/) hooks to run code quality checks locally. We recommended installing them before contributing.\n\n```console\npre-commit install\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Framework for writing serverless APIs in Python, using Scaleway functions and containers.",
    "version": "1.2.0",
    "project_urls": {
        "Documentation": "https://serverless-api-project.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/scaleway/serverless-api-framework-python",
        "Repository": "https://github.com/scaleway/serverless-api-framework-python"
    },
    "split_keywords": [
        "serverless",
        "scaleway",
        "functions",
        "cloud",
        "faas"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6ae4d75fc488120a6b3e0de984bdf3a24a5600e42e2a9e3485d3c118d1f11365",
                "md5": "ad8a48b82c189b49a250f58709968bf3",
                "sha256": "b2bf5fa92b1f018d94ce5fd934b9b44969b471701a79659b2e6fc9bf356856b6"
            },
            "downloads": -1,
            "filename": "scw_serverless-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ad8a48b82c189b49a250f58709968bf3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<3.12",
            "size": 23366,
            "upload_time": "2023-07-04T10:05:20",
            "upload_time_iso_8601": "2023-07-04T10:05:20.686632Z",
            "url": "https://files.pythonhosted.org/packages/6a/e4/d75fc488120a6b3e0de984bdf3a24a5600e42e2a9e3485d3c118d1f11365/scw_serverless-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28a5ac9e69fa569a1881e08c11ed26020be2463603d02a5ea3889757ca9c6516",
                "md5": "3b7e45f182e90ac6a6e10332e15676bc",
                "sha256": "a9e2274157833be7b93aad59ff06734cbe4f793ef508c1070940c4faee2a29cf"
            },
            "downloads": -1,
            "filename": "scw_serverless-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3b7e45f182e90ac6a6e10332e15676bc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<3.12",
            "size": 18578,
            "upload_time": "2023-07-04T10:05:22",
            "upload_time_iso_8601": "2023-07-04T10:05:22.495931Z",
            "url": "https://files.pythonhosted.org/packages/28/a5/ac9e69fa569a1881e08c11ed26020be2463603d02a5ea3889757ca9c6516/scw_serverless-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-04 10:05:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "scaleway",
    "github_project": "serverless-api-framework-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "scw-serverless"
}
        
Elapsed time: 0.21450s