Skip to main content

GCP Cloud Functions support for ASGI applications

Project description

Vellox

Package version PyPI - Python Version

Vellox is an adapter for running ASGI applications in GCP Cloud Functions.

Requirements

Python 3.8+

Example

from vellox import Vellox

async def app(scope, receive, send):
    await send(
        {
            "type": "http.response.start",
            "status": 200,
            "headers": [[b"content-type", b"text/plain; charset=utf-8"]],
        }
    )
    await send({"type": "http.response.body", "body": b"Hello, world!"})


vellox = Vellox(app=app, lifespan="off")

def handler(request):
    return vellox(request)

Or using a framework:

from fastapi import FastAPI
from vellox import Vellox

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
    return {"item_id": item_id, "q": q}

vellox = Vellox(app=app, lifespan="off")

def handler(request):
    return vellox(request)

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

vellox-0.1.2.tar.gz (8.3 kB view hashes)

Uploaded Source

Built Distribution

vellox-0.1.2-py3-none-any.whl (10.8 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