Skip to main content

No project description provided

Project description

Pyfunvice is FaaS SDK for Python

If you want to write an HTTP service based on python, your service is very simple, and at the same time you don’t want to add a complicated HTTP framework, Pyfunvice will be your best choice.

First, you need to install pyfunvice

pip install pyfunvice

And a very simple example will be provided below

from pyfunvice import faas, faas_with_dict_req, start_faas

@faas(path="/api/v1/greet")
async def v1_greet(data: dict) -> dict:
    name = data["name"]
    age = data["age"]
    return {"name": name, "age": age, "status": "success"}

if __name__ == "__main__":
    start_faas()

That's all, a HTTP service will be run and the default port is 8000 and the path is /api/v1/greet

If you want to change the default port, you can add port parameter

from pyfunvice import faas, faas_with_dict_req, start_faas

@faas(path="/api/v1/greet")
async def v1_greet(data: dict) -> dict:
    name = data["name"]
    age = data["age"]
    return {"name": name, "age": age, "status": "success"}

if __name__ == "__main__":
    start_faas(port=8080)

And if you want to increase the number of workers, you can add workers parameter, it will run n worker processes in parallel

from pyfunvice import faas, faas_with_dict_req, start_faas

@faas(path="/api/v1/greet")
async def v1_greet(data: dict) -> dict:
    name = data["name"]
    age = data["age"]
    return {"name": name, "age": age, "status": "success"}

if __name__ == "__main__":
    start_faas(port=8080, workers=2)

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

pyfunvice-0.1.4.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

pyfunvice-0.1.4-py3-none-any.whl (5.0 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