Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

0 downloads

Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.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 signup: the person chooses the password and name on the confirm page 83c7aa6 2 weeks, 5 days ago History
write_probe.py · 6.4 KB · 211 lines
1from datetime import datetime, timezone
2
3
4def GET(request):
5 served = int(_state_manager.get("served", 0) or 0) + 1
6 now = datetime.now(timezone.utc).isoformat()
7 _state_manager.set("served", served)
8 _state_manager.set("last_seen", now)
9 _logger.info("system_write_probe served", count=served)
10
11 html = f"""<!doctype html>
12<html lang="en">
13<head>
14 <meta charset="utf-8">
15 <meta name="viewport" content="width=device-width, initial-scale=1">
16 <title>DBBASIC Write Probe</title>
17 <style>
18 :root {{
19 color-scheme: dark;
20 --bg: #0b0b10;
21 --panel: #17171f;
22 --panel-2: #101018;
23 --text: #f4f4f7;
24 --muted: #a2a2ad;
25 --line: #38384a;
26 --green: #52d273;
27 --amber: #f1b747;
28 --blue: #54a7ff;
29 --red: #ff6b6b;
30 }}
31 * {{ box-sizing: border-box; }}
32 body {{
33 margin: 0;
34 min-height: 100vh;
35 background: var(--bg);
36 color: var(--text);
37 font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
38 display: grid;
39 place-items: center;
40 padding: 48px 24px;
41 }}
42 main {{
43 width: min(1120px, 100%);
44 display: grid;
45 gap: 20px;
46 }}
47 header {{
48 display: flex;
49 justify-content: space-between;
50 gap: 18px;
51 align-items: flex-start;
52 border-bottom: 1px solid var(--line);
53 padding-bottom: 24px;
54 }}
55 h1 {{
56 margin: 0;
57 font-size: clamp(42px, 6vw, 76px);
58 line-height: .95;
59 letter-spacing: 0;
60 }}
61 p {{
62 margin: 12px 0 0;
63 color: var(--muted);
64 max-width: 740px;
65 }}
66 code {{
67 font: 14px/1.4 SFMono-Regular, Menlo, Consolas, monospace;
68 color: var(--text);
69 background: var(--panel-2);
70 border: 1px solid var(--line);
71 border-radius: 6px;
72 padding: 2px 6px;
73 }}
74 .badge-row {{
75 display: flex;
76 flex-wrap: wrap;
77 gap: 10px;
78 margin-top: 20px;
79 }}
80 .badge {{
81 border: 1px solid var(--line);
82 border-radius: 999px;
83 padding: 6px 10px;
84 color: var(--muted);
85 background: var(--panel);
86 font-size: 13px;
87 font-weight: 700;
88 white-space: nowrap;
89 }}
90 .ok {{ color: var(--green); }}
91 .warn {{ color: var(--amber); }}
92 .grid {{
93 display: grid;
94 grid-template-columns: repeat(3, minmax(0, 1fr));
95 gap: 16px;
96 }}
97 .card {{
98 min-height: 160px;
99 border: 1px solid var(--line);
100 border-radius: 8px;
101 background: var(--panel);
102 padding: 20px;
103 }}
104 h2 {{
105 margin: 0 0 12px;
106 font-size: 18px;
107 letter-spacing: 0;
108 }}
109 .row {{
110 display: flex;
111 justify-content: space-between;
112 gap: 16px;
113 border-top: 1px solid var(--line);
114 padding: 10px 0;
115 color: var(--muted);
116 }}
117 .row:first-of-type {{ border-top: 0; }}
118 .row span:last-child {{
119 color: var(--text);
120 text-align: right;
121 font-weight: 700;
122 }}
123 .terminal {{
124 border: 1px solid var(--line);
125 border-radius: 8px;
126 background: #050506;
127 overflow-x: auto;
128 padding: 16px;
129 color: #d9ecff;
130 font: 13px/1.55 SFMono-Regular, Menlo, Consolas, monospace;
131 }}
132 .terminal .comment {{ color: var(--muted); }}
133 .terminal .method {{ color: var(--green); }}
134 .terminal .url {{ color: var(--blue); }}
135 footer {{
136 display: flex;
137 justify-content: space-between;
138 gap: 16px;
139 color: #787887;
140 font-size: 13px;
141 }}
142 @media (max-width: 900px) {{
143 header {{ display: grid; }}
144 .grid {{ grid-template-columns: 1fr; }}
145 footer {{ display: grid; }}
146 }}
147 </style>
148</head>
149<body>
150 <main>
151 <header>
152 <div>
153 <h1>DBBASIC Write Probe</h1>
154 <p>
155 This page is served by one installed object. It writes only its own object state.
156 Collection record writes stay behind the server admin-token gate.
157 </p>
158 <div class="badge-row">
159 <span class="badge ok">object state write: on</span>
160 <span class="badge warn">collection writes: admin-token gated</span>
161 <span class="badge">source writes: disabled by default</span>
162 </div>
163 </div>
164 <div class="card">
165 <h2>Probe Object</h2>
166 <div class="row"><span>object</span><span>system_write_probe</span></div>
167 <div class="row"><span>served</span><span>{served} times</span></div>
168 <div class="row"><span>last seen</span><span>{now}</span></div>
169 </div>
170 </header>
171
172 <section class="grid" aria-label="write surfaces">
173 <article class="card">
174 <h2>Object State</h2>
175 <div class="row"><span>store</span><span>state TSV</span></div>
176 <div class="row"><span>key</span><span>served</span></div>
177 <div class="row"><span>route</span><span>/admin/write-probe</span></div>
178 </article>
179 <article class="card">
180 <h2>Collection Records</h2>
181 <div class="row"><span>collection</span><span>dbbasic_probe</span></div>
182 <div class="row"><span>schema</span><span>installed</span></div>
183 <div class="row"><span>auth</span><span>admin token</span></div>
184 </article>
185 <article class="card">
186 <h2>Public Staging</h2>
187 <div class="row"><span>listing</span><span>blocked</span></div>
188 <div class="row"><span>source writes</span><span>off</span></div>
189 <div class="row"><span>route policy</span><span>allowlist</span></div>
190 </article>
191 </section>
192
193 <section class="terminal" aria-label="admin write probe example">
194 <div><span class="comment"># narrow public route, still server-gated by Authorization</span></div>
195 <div><span class="method">POST</span> <span class="url">/collections/dbbasic_probe/records</span></div>
196 <div>{{"id":"probe_001","status":"created","note":"admin write test"}}</div>
197 <br>
198 <div><span class="method">PUT</span> <span class="url">/collections/dbbasic_probe/records/probe_001</span></div>
199 <div>{{"status":"updated","note":"update path works"}}</div>
200 <br>
201 <div><span class="method">DELETE</span> <span class="url">/collections/dbbasic_probe/records/probe_001</span></div>
202 </section>
203
204 <footer>
205 <span>Installed from <code>packages/admin-write-probe</code>.</span>
206 <span>Designed to prove write paths before broader admin APIs are exposed.</span>
207 </footer>
208 </main>
209</body>
210</html>"""
211 return {"content_type": "text/html; charset=utf-8", "body": html}