No project description provided
Project description
Pinnacle Python Client
This is the official Python client for the Pinnacle Serverless Backend API.
Pre-requisites
- Python 3.12 or higher
Usage
- Install the package using pip:
pip install pinnacle-python
- Create a directory called
pinnacleand create a file calledmain.pyin the directory. This directory will contain all your endpoint definitions. - To define an endpoint, use the
@endpointdecorator:
from pinnacle_python import endpoint
@endpoint()
def hello_world():
return "Hello, World!"
This will create a POST endpoint at /hello_world with no parameters.
- To define a scheduled script, use the
@scheduleddecorator:
from pinnacle_python import schedule, Period
@schedule(
for_time=datetime.datetime.today() + timedelta(minutes=1),
repeats=Period(seconds=2)
)
def test_job():
print("Hello, world!")
This will run the test_job function every 2 seconds starting 1 minute from the time the script is deployed. See the schedule documentation for more information on how to configure the schedule.
- Install the Pinnacle CLI:
pip install pinnacle-cli
- Deploy the endpoint using the CLI:
pinnacle dev
- You can now access the endpoint at
http://localhost:8000/hello_world. Calling the endpoint
curl -X POST http://localhost:8000/hello_world \
-H "Content-Type: application/json" \
-d '{}'
will return a JSON in the following format:
{
"data": "Hello, World!"
}
Defining response models
If you want to define a response model for your endpoint, provide the return type for the endpoint function:
from pinnacle_python import endpoint
@endpoint()
def hello_world() -> int:
return 1
Or, if you want to return a more complex object use Pydantic's BaseModel class:
from pydantic import BaseModel
from pinnacle_python import endpoint
class Person(BaseModel):
name: str
message: str
@endpoint()
def hello_world() -> Person:
return Person(name="John", message="Hello, World!")
Environment Variables
See the Pinnacle CLI README for a list of environment variables that can be used to configure the Pinnacle CLI.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pinnacle_python-0.0.3.tar.gz.
File metadata
- Download URL: pinnacle_python-0.0.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c76f6c0aa70249591ccbfc7a638e46518caa58e5561efcecc58c6b34b4a58ce
|
|
| MD5 |
7d033596d0b124a9c8c950d88bb1fdbd
|
|
| BLAKE2b-256 |
ab55184b32bf6b3793e7cd91f7254fd18edf056b822c8f94378e232b5883ced9
|
File details
Details for the file pinnacle_python-0.0.3-py3-none-any.whl.
File metadata
- Download URL: pinnacle_python-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7871249aac0e9dedb89853aae5cc3354798c0e68ff5a4532920ef2f2854100cf
|
|
| MD5 |
dd208dd05815b37b0f8ea6bcf7a6d30f
|
|
| BLAKE2b-256 |
9404b64d8619203b8fdfc020080a8506341f219ddbaf3ac9c10e1ac6b854c008
|