askrobots / dbbasic-admin
Public
An admin interface that builds itself from the dbbasic modules you install; its pages follow file paths, like CGI.
nav.py · 624 bytes · 26 lines
| 1 | """ |
| 2 | API endpoint for navigation items. |
| 3 | |
| 4 | Route: /admin/api/nav |
| 5 | Returns: JSON array of navigation items |
| 6 | """ |
| 7 | |
| 8 | import json |
| 9 | from dbbasic_web.responses import json as json_response |
| 10 | from dbbasic_admin.admin import build_nav |
| 11 | |
| 12 | |
| 13 | def handle(request): |
| 14 | """ |
| 15 | Return navigation items as JSON. |
| 16 | |
| 17 | This endpoint is called by the admin UI to dynamically |
| 18 | build the sidebar navigation from core + discovered modules. |
| 19 | |
| 20 | Returns: |
| 21 | JSON response with nav items array |
| 22 | """ |
| 23 | nav_items = build_nav() |
| 24 | |
| 25 | # Return as JSON using dbbasic_web's json response helper |
| 26 | return json_response(json.dumps(nav_items, indent=2)) |