Example DBBasic apps (an API, a blog and a microblog) and a template for new DBBasic modules.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-examples.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-examples.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-examples.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add official module template for creating DBBasic packages 17cf88a 1 year, 1 month ago History
api.py · 1.0 KB · 27 lines
1from dbbasic_web.responses import json
2import json as json_lib
3
4def handle(request):
5 """API documentation endpoint"""
6 docs = {
7 "name": "DBBasic Tasks API",
8 "version": "1.0",
9 "endpoints": {
10 "GET /": "API documentation",
11 "GET /health": "Health check",
12 "POST /auth/register": "Register new user",
13 "POST /auth/login": "Login and get token",
14 "POST /auth/logout": "Logout and invalidate token",
15 "GET /tasks": "List all tasks (supports ?status=done&search=foo&page=1&limit=20)",
16 "POST /tasks": "Create new task",
17 "GET /tasks/<id>": "Get task by ID",
18 "PUT /tasks/<id>": "Update task",
19 "DELETE /tasks/<id>": "Delete task"
20 },
21 "authentication": {
22 "type": "Bearer token",
23 "header": "Authorization: Bearer <token>",
24 "obtain": "POST /auth/login with email and password"
25 }
26 }
27 return json(json_lib.dumps(docs, indent=2))