Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /terrene-foundation_kailash-py /packages /kailash-nexus /examples /quick_demo.py
| #!/usr/bin/env python3 | |
| """ | |
| NEXUS QUICK DEMO: Zero FastAPI Coding Required | |
| ============================================== | |
| Quick demo showing Nexus workflow-to-API automation works perfectly. | |
| Usage: | |
| cd packages/kailash-nexus | |
| python examples/quick_demo.py | |
| Then test: | |
| curl -X POST http://localhost:8080/workflows/greeter/execute -H "Content-Type: application/json" -d '{"name": "Alice"}' | |
| """ | |
| import os | |
| import sys | |
| # Add src to Python path so we can import nexus | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src")) | |
| from kailash.workflow.builder import WorkflowBuilder | |
| from nexus import Nexus | |
| def create_simple_workflow(): | |
| """Create a simple greeting workflow.""" | |
| workflow = WorkflowBuilder() | |
| greeting_code = """ | |
| name = parameters.get('name', 'World') | |
| message = parameters.get('message', 'Hello') | |
| result = {'greeting': f'{message}, {name}!', 'name': name, 'timestamp': '2025-01-15T10:00:00Z'} | |
| """ | |
| workflow.add_node("PythonCodeNode", "greet", {"code": greeting_code.strip()}) | |
| return workflow | |
| def main(): | |
| """Quick demo of Nexus capabilities.""" | |
| print("๐ Nexus Quick Demo - Zero FastAPI Coding Required") | |
| print("=" * 55) | |
| # STEP 1: Zero-config initialization | |
| app = Nexus(api_port=8080, mcp_port=3002) # Use different ports | |
| print("โ Nexus initialized (ports: API=8080, MCP=3002)") | |
| # STEP 2: Register workflow - Single call โ API + CLI + MCP | |
| workflow = create_simple_workflow() | |
| app.register("greeter", workflow) | |
| print("โ Workflow registered โ Available on API + CLI + MCP") | |
| # STEP 3: Start platform | |
| try: | |
| print("\n๐ Starting platform...") | |
| app.start() | |
| # Check health | |
| health = app.health_check() | |
| print(f"๐ Status: {health.get('status', 'unknown')}") | |
| print("\n" + "=" * 55) | |
| print("๐ SUCCESS! Platform running with ZERO FastAPI coding!") | |
| print("=" * 55) | |
| print("\n๐ก Available Endpoints:") | |
| print(" ๐ API: http://localhost:8080") | |
| print(" POST /workflows/greeter/execute") | |
| print(" GET /workflows") | |
| print(" GET /health") | |
| print(" ๐ค MCP: ws://localhost:3002 (for AI agents)") | |
| print("\n๐งช Test Command:") | |
| print(" curl -X POST http://localhost:8080/workflows/greeter/execute \\") | |
| print(" -H 'Content-Type: application/json' \\") | |
| print(' -d \'{"name": "Alice", "message": "Welcome"}\'') | |
| print("\n๐ก PROOF: This required:") | |
| print(" โ 0 lines of FastAPI code") | |
| print(" โ 0 route definitions") | |
| print(" โ 0 middleware setup") | |
| print(" โ Just workflow + app.register()!") | |
| print("\nโน๏ธ Press Ctrl+C to stop...") | |
| # Run for 30 seconds to allow testing | |
| import time | |
| start_time = time.time() | |
| while time.time() - start_time < 30: | |
| time.sleep(1) | |
| print("\nโฐ Demo timeout reached - stopping platform...") | |
| app.stop() | |
| print("โ Platform stopped gracefully") | |
| return True | |
| except KeyboardInterrupt: | |
| print("\n\n๐ Demo stopped by user") | |
| app.stop() | |
| print("โ Platform stopped gracefully") | |
| return True | |
| except Exception as e: | |
| print(f"โ Error: {e}") | |
| print("๐ Possible causes:") | |
| print(" โข Ports 8080/3002 in use") | |
| print(" โข Missing dependencies") | |
| return False | |
| if __name__ == "__main__": | |
| success = main() | |
| if success: | |
| print("\n๐ Demo completed successfully!") | |
| print("โ Nexus provides complete workflow-to-API automation") | |
| print("โ Zero FastAPI coding required") | |
| print("โ Multi-channel platform (API + CLI + MCP)") | |
| else: | |
| print("\nโ Demo failed - check error messages above") | |
| exit(1) | |
Xet Storage Details
- Size:
- 3.87 kB
- Xet hash:
- da61ce9a087f0a6b3c86dba85fd113cfd7715f361b062940d18afe565116afc3
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.