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
post.py · 508 bytes · 17 lines
1from dbbasic.tsv import TSV
2from dbbasic_web.responses import html, json_error
3from dbbasic_web.templating import render
4
5posts = TSV("posts", ["id", "title", "content", "author", "created"])
6
7def handle(request):
8 # /post/<post_id>
9 post_id = request.path_param(1)
10 if not post_id:
11 return json_error("Invalid path", status=404)
12
13 post = posts.query_one(id=post_id)
14 if not post:
15 return json_error("Post not found", status=404)
16
17 return html(render('post.html', post=post))