askrobots / dbbasic-web
Public
A Unix-style Python web framework: filesystem routing, flat files, messages and cron, with CGI's simplicity at modern speed.
Dan Quellhorst
Replace multipart parser with stdlib-only implementation
eb957a2
9 months, 2 weeks ago
History
hello.py · 365 bytes · 10 lines
| 1 | """Simple hello API endpoint - demonstrates basic routing""" |
| 2 | import json |
| 3 | from dbbasic_web.responses import json as json_response |
| 4 | |
| 5 | |
| 6 | def handle(request): |
| 7 | """Handle /hello and /hello?name=World""" |
| 8 | name = request.get("query", {}).get("name", "world") |
| 9 | body = json.dumps({"message": f"Hello, {name}!", "path": request["path"]}) |
| 10 | return json_response(body) |