Python functions as REST objects, with clustering, load balancing and state replication; no containers or orchestration.

0 downloads

dbbasic-object-primitive/examples/tutorial/02_hello_with_logging.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-primitive.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-primitive.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-primitive.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Dan Q Consolidate duplicate QUICKSTARTs on the top-level file 503f830 7 months ago History
02_hello_with_logging.py · 609 bytes · 29 lines
1"""
202_hello_with_logging.py - Object with self-logging
3"""
4
5# The runtime will inject these
6_logger = None
7_state_manager = None
8
9
10def GET(request):
11 """Return a greeting with logging"""
12
13 # Extract user info from request
14 user_id = request.get('user_id', 'anonymous')
15 ip_address = request.get('ip_address', 'unknown')
16
17 # Log the request
18 if _logger:
19 _logger.info(
20 'Greeting requested',
21 user_id=user_id,
22 ip_address=ip_address,
23 )
24
25 # Return greeting
26 return {
27 'status': 'ok',
28 'message': f'Hello, {user_id}!',
29 }