Python functions as REST objects, with clustering, load balancing and state replication; no containers or orchestration.
Examples
Copy-paste examples with test commands.
Tutorial Examples
Located in examples/tutorial/
1. Hello World
File: examples/tutorial/01_hello.py
Test:
curl http://localhost:8001/objects/tutorial_01_hello
2. Hello with Logging
File: examples/tutorial/02_hello_with_logging.py
Test:
curl http://localhost:8001/objects/tutorial_02_hello_with_logging
View logs:
curl http://localhost:8001/objects/tutorial_02_hello_with_logging?logs=true
3. Counter
File: examples/tutorial/03_counter.py
Increment counter:
curl http://localhost:8001/objects/tutorial_03_counter
curl http://localhost:8001/objects/tutorial_03_counter
curl http://localhost:8001/objects/tutorial_03_counter
Each call increments the count.
4. Calculator
File: examples/tutorial/04_calculator.py
Add:
curl -X POST http://localhost:8001/objects/tutorial_04_calculator \
-H "Content-Type: application/json" \
-d '{"operation": "add", "value": 5}'
Multiply:
curl -X POST http://localhost:8001/objects/tutorial_04_calculator \
-H "Content-Type: application/json" \
-d '{"operation": "multiply", "value": 3}'
Get result:
curl http://localhost:8001/objects/tutorial_04_calculator
5. User Registry
File: examples/tutorial/05_user_registry.py
Register user:
curl -X POST http://localhost:8001/objects/tutorial_05_user_registry \
-H "Content-Type: application/json" \
-d '{"action": "register", "username": "alice", "email": "alice@example.com"}'
List users:
curl http://localhost:8001/objects/tutorial_05_user_registry
6. Task Queue
File: examples/tutorial/06_task_queue.py
Add task:
curl -X POST http://localhost:8001/objects/tutorial_06_task_queue \
-H "Content-Type: application/json" \
-d '{"action": "add", "task": "Process invoice"}'
Get next task:
curl http://localhost:8001/objects/tutorial_06_task_queue?action=next
Advanced Examples
Auth System
File: examples/advanced/auth.py
Register:
curl -X POST http://localhost:8001/objects/advanced_auth \
-H "Content-Type: application/json" \
-d '{"action": "register", "email": "user@example.com", "password": "secret123", "password_confirm": "secret123"}'
Login:
curl -X POST http://localhost:8001/objects/advanced_auth \
-H "Content-Type: application/json" \
-d '{"action": "login", "email": "user@example.com", "password": "secret123"}'
Returns a token. Use it for authenticated requests.
Blog System
File: examples/advanced/blog.py
Create post:
curl -X POST http://localhost:8001/objects/advanced_blog \
-H "Content-Type: application/json" \
-d '{
"action": "create",
"title": "My First Post",
"content": "This is the content of my first blog post.",
"author": "alice",
"tags": ["intro", "test"]
}'
List posts:
curl http://localhost:8001/objects/advanced_blog
Search:
curl "http://localhost:8001/objects/advanced_blog?search=first"
Creating Your Own
Basic template:
def GET(request):
"""Handle GET requests"""
return {"status": "ok"}
def POST(request):
"""Handle POST requests"""
data = request.get('data')
return {"received": data}
With state:
def POST(request):
"""Save and retrieve data"""
key = request.get('key')
value = request.get('value')
if value:
_state_manager.set(key, value)
return {"saved": key}
else:
stored = _state_manager.get(key, '')
return {"value": stored}
With logging:
def POST(request):
"""Log all actions"""
action = request.get('action')
_logger.log('action', {
'type': action,
'timestamp': time.time()
})
return {"logged": action}
Next Steps
- API Reference - All available endpoints
- Cluster Setup - Distribute your objects