Below is a fully-working “no-dependencies” skeleton you can drop in a single folder, start with one command, and immediately open in a browser. It lets you
• read the current Markdown table stored in tasks.md
• add rows / mark rows “done” or “not done” in the browser
• save the result back into tasks.md
• copy the visible table to your clipboard as Markdown with one click
Everything is done with the Python standard library (http.server) plus plain HTML + CSS + vanilla JavaScript.
──────────────────────────────
- Folder layout (all files in the same dir)
──────────────────────────────
project/
│ server.py ← tiny HTTP server & JSON API
│ index.html ← UI template
│ tasks.md ← the data file (created automatically if missing)
└── style.css ← optional styling (can be inlined if you prefer)
──────────────────────────────
2. Markdown file format
──────────────────────────────
tasks.md is an ordinary Markdown table:
| Task | Done |
|---|
| Buy milk | [ ] |
| Fix bug #42 | [x] |
Done column uses “[ ]” (space) for not-done and “[x]” for done.
──────────────────────────────
3. server.py (≈ 120 lines)
──────────────────────────────
#!/usr/bin/env python3
"""
Tiny zero-dependency backend that:
• serves index.html & style.css (static)
• exposes two JSON endpoints
GET /api/tasks -> list of dicts [{task:"Buy milk", done:false}, …]
POST /api/tasks -> overwrite tasks.md with posted list
"""
import http.server, json, os, urllib.parse, pathlib, html
FILENAME = pathlib.Path(__file__).with_name("tasks.md")
HOST, PORT = "localhost", 8000
# ------------------------------------------------------------------ helpers
def ensure_md_exists():
if not FILENAME.exists():
FILENAME.write_text("| Task | Done |\n|------|------|\n")
def parse_md() -> list:
"""Return list[dict] from tasks.md"""
lines = [ln.rstrip("\n") for ln in FILENAME.read_text().splitlines()]
rows = [ln for ln in lines if ln.lstrip().startswith("|")]
data = []
for row in rows[2:]: # skip header + separator
cells = [c.strip() for c in row.strip("|").split("|")]
if len(cells) >= 2:
task = cells[0]
done = cells[1].lower().startswith("[x]")
data.append({"task": task, "done": done})
return data
def write_md(rows: list):
header = "| Task | Done |\n|------|------|\n"
body = "".join(f"| {html.escape(r['task'])} | {'[x]' if r['done'] else '[ ]'} |\n"
for r in rows)
FILENAME.write_text(header + body)
# ------------------------------------------------------------------ handler
class Handler(http.server.SimpleHTTPRequestHandler):
def _send_json(self, obj, code=200):
blob = json.dumps(obj).encode()
self.send_response(code)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(blob)))
self.end_headers()
self.wfile.write(blob)
def do_GET(self):
if self.path.startswith("/api/tasks"):
self._send_json(parse_md())
else:
super().do_GET() # index.html, style.css, etc.
def do_POST(self):
if self.path.startswith("/api/tasks"):
length = int(self.headers.get("Content-Length", 0))
data = json.loads(self.rfile.read(length))
write_md(data)
self._send_json({"status": "ok"})
else:
self.send_error(404, "Unknown POST endpoint")
# ------------------------------------------------------------------ run
if __name__ == "__main__":
ensure_md_exists()
http.server.ThreadingHTTPServer((HOST, PORT), Handler).serve_forever()
──────────────────────────────
4. index.html (≈ 110 lines incl. JS)
──────────────────────────────
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Local Task Table</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>🗒️ My Tasks</h1>
<table id="taskTable">
<thead>
<tr><th>Task</th><th>Done</th><th>Actions</th></tr>
</thead>
<tbody><!-- rows injected by JS --></tbody>
</table>
<button id="addRowBtn">➕ Add row</button>
<button id="saveBtn">💾 Save to tasks.md</button>
<button id="copyBtn">📋 Copy table as Markdown</button>
<script>
const API = '/api/tasks';
const tbody = document.querySelector('#taskTable tbody');
function rowHTML(task='', done=false){
return `<tr>
<td contenteditable="true">${task.replace(/&/g,'&')}</td>
<td><input type="checkbox" ${done?'checked':''}></td>
<td><button onclick="this.closest('tr').remove()">🗑️</button></td>
</tr>`;
}
async function load(){
const res = await fetch(API); const data = await res.json();
tbody.innerHTML = data.map(r=>rowHTML(r.task,r.done)).join('');
}
async function save(){
const rows=[...tbody.querySelectorAll('tr')].map(tr=>{
return {
task: tr.cells[0].innerText.trim(),
done: tr.cells[1].querySelector('input').checked
};
});
await fetch(API,{method:'POST',body:JSON.stringify(rows)});
alert('✅ Saved!');
}
function addRow(){ tbody.insertAdjacentHTML('beforeend',rowHTML()); }
function copyMarkdown(){
const header='| Task | Done |\\n|------|------|\\n';
const body=[...tbody.querySelectorAll('tr')].map(tr=>{
const task=tr.cells[0].innerText.trim().replace('|','\\|');
const done=tr.cells[1].querySelector('input').checked?'[x]':'[ ]';
return `| ${task} | ${done} |`;
}).join('\\n');
navigator.clipboard.writeText(header+body).then(()=>alert('📋 Copied!'));
}
document.getElementById('addRowBtn').onclick = addRow;
document.getElementById('saveBtn').onclick = save;
document.getElementById('copyBtn').onclick = copyMarkdown;
load();
</script>
</body>
</html>
──────────────────────────────
5. style.css (optional, tweak at will)
──────────────────────────────
body{font-family:sans-serif;margin:40px;}
table{border-collapse:collapse;width:100%;}
th,td{border:1px solid #ccc;padding:6px;}
td[contenteditable]{background:#fffff6;}
tr:nth-child(even){background:#f9f9f9;}
button{margin-top:8px;margin-right:6px;padding:6px 10px;}
──────────────────────────────
6. How to run
──────────────────────────────
$ python server.py
The first run auto-creates tasks.md with an empty header.
After you edit/save, reload the page and you’ll see the persisted data.
──────────────────────────────
7. Extending ideas
──────────────────────────────
• Add “delete-all-done” button (filter rows in JS, then save)
• Sort rows alphabetically or by done-status
• Use query‐string ?dark=1 and switch CSS theme server-side
• Serve multiple tables (different .md files) by passing filename in path
Have fun building!