A form builder that keeps forms and responses in TSV files: git-friendly, no database, CSV export.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-forms.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-forms.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-forms.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 Fix API handlers for dbbasic-web compatibility (v1.0.1) 143a3f2 1 year, 1 month ago History
delete.py · 1.1 KB · 39 lines
1"""
2Delete form (admin interface)
3POST /admin/forms/{form_id}/delete - Delete form and all responses
4"""
5
6import json
7from dbbasic_forms import FormBuilder
8
9
10def handle(request):
11 """Delete a form and all its responses"""
12 # Extract form_id from path
13 # Path format: /admin/forms/{form_id}/delete
14 path_parts = request.path.strip("/").split("/")
15 if len(path_parts) < 3:
16 return {
17 "status": 400,
18 "headers": {"Content-Type": "application/json"},
19 "body": json.dumps({"error": "Invalid path"}),
20 }
21
22 form_id = path_parts[2] # forms/{form_id}/delete
23
24 # Delete form
25 builder = FormBuilder()
26 deleted = builder.delete_form(form_id)
27
28 if deleted:
29 return {
30 "status": 200,
31 "headers": {"Content-Type": "application/json"},
32 "body": json.dumps({"success": True, "message": f"Form '{form_id}' deleted"}),
33 }
34 else:
35 return {
36 "status": 404,
37 "headers": {"Content-Type": "application/json"},
38 "body": json.dumps({"error": "Form not found"}),
39 }