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 · 693 bytes · 25 lines
1from dbbasic.tsv import TSV
2from dbbasic_web.responses import redirect
3from dbbasic_accounts import Accounts
4import time
5
6accounts = Accounts('.', domain='localhost')
7posts = TSV("posts", ["id", "username", "content", "created"])
8
9def handle(request):
10 user, auth_error = request.require_auth(accounts)
11 if auth_error:
12 return auth_error
13
14 if request.method == 'POST':
15 content = request.param('content', '')
16 post_id = str(int(time.time() * 1000))
17
18 posts.insert({
19 'id': post_id,
20 'username': user.username,
21 'content': content,
22 'created': time.strftime('%Y-%m-%d %H:%M')
23 })
24
25 return redirect('/')