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

0 downloads

dbbasic-object-primitive/run_server.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
run_server.py · 1.6 KB · 52 lines
1#!/usr/bin/env python3
2"""
3Run the dbbasic-web server for the Object Primitive System
4
5Usage:
6 python run_server.py
7
8Then access:
9 http://localhost:8000/objects - List all objects
10 http://localhost:8000/objects/basics_counter - Execute counter object
11"""
12import os
13import uvicorn
14from pathlib import Path
15
16# Set station ID (station1 is master)
17os.environ['STATION_ID'] = 'station1'
18
19# Set the base directory for dbbasic-web routing
20import dbbasic_web.settings
21dbbasic_web.settings.BASE_DIR = Path(__file__).parent
22
23if __name__ == "__main__":
24 print("=" * 60)
25 print("Object Primitive System REST API Server")
26 print("=" * 60)
27 print()
28 print("Server starting on http://localhost:8000")
29 print()
30 print("Available endpoints:")
31 print(" GET /objects - List all objects")
32 print(" GET /objects/{id} - Execute object's GET method")
33 print(" GET /objects/{id}?source=true - View source code")
34 print(" GET /objects/{id}?metadata=true - View metadata")
35 print(" GET /objects/{id}?logs=true - View logs")
36 print(" GET /objects/{id}?versions=true - View version history")
37 print(" POST /objects/{id} - Execute object's POST method")
38 print(" PUT /objects/{id} - Execute object's PUT method")
39 print(" PUT /objects/{id}?source=true - Update code")
40 print(" DELETE /objects/{id} - Execute object's DELETE method")
41 print()
42 print("Press Ctrl+C to stop")
43 print("=" * 60)
44 print()
45
46 uvicorn.run(
47 "dbbasic_web.asgi:app",
48 host="0.0.0.0",
49 port=8001,
50 reload=True, # Auto-reload on code changes
51 log_level="info",
52 )