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
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
pyfunvice-0.1.11.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for pyfunvice-0.1.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5c814d148db8951ac83e4522d73924267d412eabe53c6e5b891eff847c95b75 |
|
MD5 | a69d7f2fadfc03c08abc297c1f42aa22 |
|
BLAKE2b-256 | 7e5f46111c6550d5fc4d60cf38da38102a537e010fd8e3740c86d454e22038f4 |