Turn your Python functions, classes, and objects into remote services instantly.
Project description
SnapServe
Turn your Python functions, classes, and objects into remote services instantly.
SnapServe is a lightweight framework that exposes your Python code as a remote service with a single command. It lets you serve functions, classes, or stateful objects without writing any API boilerplate, and interact with them through a simple Python client.
Instead of building and maintaining server code (e.g., with FastAPI or Flask), you focus on your application logic, SnapServe handles the serving layer and execution for you.
📦 Install
pip install snapserve
🚀 Quick Start
🔹 Serve Functions
Expose one or more functions with a single command:
# calculator.py
def add(a: float, b: float) -> float:
return a + b
def subtract(a: float, b: float) -> float:
return a - b
snapserve serve calculator:add,subtract
🌐 SnapServe is live:
(function) add(a: float, b: float) -> float
(function) subtract(a: float, b: float) -> float
Call them from Python:
from snapserve import remote
add = remote("add")
subtract = remote("subtract")
print(add(5, 3)) # → 8
print(subtract(5, 3)) # → 2
SnapServe supports multiple Python abstractions with a unified interface.
🔹 Serve Classes
Serve a class definition. Each call creates a new isolated instance on the server.
# calculator_class.py
class Calculator:
def add(self, a: float, b: float) -> float:
return a + b
def subtract(self, a: float, b: float) -> float:
return a - b
snapserve serve calculator_class:Calculator
from snapserve import remote
Calculator = remote("Calculator")
calc = Calculator()
print(calc.add(5, 3)) # → 8
print(calc.subtract(5, 3)) # → 2
🔹 Serve Objects (Stateful)
Serve an existing object to preserve state across calls.
# calculator_class.py
class Calculator:
def __init__(self):
self.last_result = None
def add(self, a: float, b: float) -> float:
self.last_result = a + b
return self.last_result
def subtract(self, a: float, b: float) -> float:
self.last_result = a - b
return self.last_result
calc = Calculator()
snapserve serve calculator_class:calc
from snapserve import remote
calc = remote("calc")
print(calc.add(5, 3)) # → 8
print(calc.last_result) # → 8
print(calc.subtract(5, 3)) # → 2
print(calc.last_result) # → 2
🔧 Configuration
snapserve provides flexible runtime configuration via CLI flags:
snapserve serve calculator:add,subtract \
--host localhost \ # Bind address (default: localhost)
--port 8080 \ # Port (default: 8000)
--workers 4 \ # Worker threads (default: 2 × CPU cores)
--max-concurrency 100 \ # Max concurrent requests
--timeout 30 \ # Request timeout (seconds)
--cachable \ # Enable result caching
--cache-size 10000 # Cache capacity
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
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 snapserve-1.1.2.tar.gz.
File metadata
- Download URL: snapserve-1.1.2.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b7e34fd35b84a111511e606ffa55d3cb13e2edb208e78c76a2e9dd32b10c9e8
|
|
| MD5 |
cfa20d097ac19d86cc06a001c9a23aa0
|
|
| BLAKE2b-256 |
a3ba957241886aa00894f4e96d397132b894683dccc28c97a1e7f07fb080f700
|
Provenance
The following attestation bundles were made for snapserve-1.1.2.tar.gz:
Publisher:
python-publish.yml on panuthept/snapserve
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snapserve-1.1.2.tar.gz -
Subject digest:
9b7e34fd35b84a111511e606ffa55d3cb13e2edb208e78c76a2e9dd32b10c9e8 - Sigstore transparency entry: 1305160262
- Sigstore integration time:
-
Permalink:
panuthept/snapserve@26f6373c76482e218068b57991d864c2fd2c2d66 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/panuthept
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@26f6373c76482e218068b57991d864c2fd2c2d66 -
Trigger Event:
release
-
Statement type:
File details
Details for the file snapserve-1.1.2-py3-none-any.whl.
File metadata
- Download URL: snapserve-1.1.2-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
068af3454ab9a47fe2b97df30d2e4c09c6166ff04bf99dfecea4bbbd7d1cee2f
|
|
| MD5 |
6d53e82e3c8be6f1c24ba343e0ac9a2e
|
|
| BLAKE2b-256 |
fa2f71f7177f355d69735ad63a552a976e7714041194ed7be73d20a1ac3a0482
|
Provenance
The following attestation bundles were made for snapserve-1.1.2-py3-none-any.whl:
Publisher:
python-publish.yml on panuthept/snapserve
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snapserve-1.1.2-py3-none-any.whl -
Subject digest:
068af3454ab9a47fe2b97df30d2e4c09c6166ff04bf99dfecea4bbbd7d1cee2f - Sigstore transparency entry: 1305160378
- Sigstore integration time:
-
Permalink:
panuthept/snapserve@26f6373c76482e218068b57991d864c2fd2c2d66 -
Branch / Tag:
refs/tags/v1.1.2 - Owner: https://github.com/panuthept
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@26f6373c76482e218068b57991d864c2fd2c2d66 -
Trigger Event:
release
-
Statement type: