askrobots / dbbasic-object-primitive
Public
Python functions as REST objects, with clustering, load balancing and state replication; no containers or orchestration.
run_server.py · 1.6 KB · 52 lines
| 1 | #!/usr/bin/env python3 |
| 2 | """ |
| 3 | Run the dbbasic-web server for the Object Primitive System |
| 4 | |
| 5 | Usage: |
| 6 | python run_server.py |
| 7 | |
| 8 | Then access: |
| 9 | http://localhost:8000/objects - List all objects |
| 10 | http://localhost:8000/objects/basics_counter - Execute counter object |
| 11 | """ |
| 12 | import os |
| 13 | import uvicorn |
| 14 | from pathlib import Path |
| 15 | |
| 16 | # Set station ID (station1 is master) |
| 17 | os.environ['STATION_ID'] = 'station1' |
| 18 | |
| 19 | # Set the base directory for dbbasic-web routing |
| 20 | import dbbasic_web.settings |
| 21 | dbbasic_web.settings.BASE_DIR = Path(__file__).parent |
| 22 | |
| 23 | if __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 | ) |