Skip to content
TheChatArchiveThe Chat Archive
Qwenqwen3-30b-a3b· Alibaba (Qwen)Hugging Face LMArena Human Preference 140K

I want create some local simple site using only html/css/py backend but zero deps on for…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-7-sonnet-20250219’s answer.
  1. User

    I want create some local simple site using only html/css/py backend but zero deps on for local use purposes. Site has to support .md in translating table case, so I want be able create tables, add new rows with task names and marker done or not, and impornatn thing button for each table allowing copy this table as md. I have to be able add new table and see it on page saving them in same .md file. UI has to have "+ ADD" in 'future' row , UI ON YOU GO

  2. Qwen Assistant

    Here's a complete, self-contained solution using only HTML, CSS, and Python (with no external dependencies). This app allows you to:

    • Create tables with task names and a "done" checkbox.
    • Add new rows dynamically.
    • Copy tables as Markdown.
    • Save all tables in a single .md file.
    • Add new tables via a "+ ADD" button.

    📁 File Structure

    task-manager/
    ├── index.html
    ├── server.py
    └── tables.md
    

    ✅ 1. index.html (Frontend UI)

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <title>Markdown Task Tables</title>
      <style>
        body {
          font-family: Arial, sans-serif;
          max-width: 900px;
          margin: 2rem auto;
          padding: 0 1rem;
        }
        h1 {
          text-align: center;
        }
        .table-container {
          border: 1px solid #ccc;
          border-radius: 8px;
          padding: 1rem;
          margin-bottom: 2rem;
        }
        table {
          width: 100%;
          border-collapse: collapse;
          margin-top: 1rem;
        }
        th, td {
          border: 1px solid #ccc;
          padding: 0.5rem;
          text-align: left;
        }
        th {
          background-color: #f0f0f0;
        }
        .controls {
          display: flex;
          justify-content: space-between;
          margin-top: 1rem;
        }
        button {
          padding: 0.5rem 1rem;
          border: none;
          border-radius: 4px;
          cursor: pointer;
        }
        .add-row {
          background-color: #4CAF50;
          color: white;
        }
        .copy-md {
          background-color: #FFA726;
          color: white;
        }
        .add-table {
          display: block;
          margin: 1rem auto;
          padding: 0.5rem 1rem;
          background-color: #2196F3;
          color: white;
          border: none;
          border-radius: 4px;
        }
        .new-table-form {
          margin-top: 1rem;
          padding: 1rem;
          border: 1px solid #ccc;
          border-radius: 4px;
          display: none;
        }
        input[type="text"] {
          width: 100%;
          padding: 0.5rem;
          margin-bottom: 0.5rem;
        }
      </style>
    </head>
    <body>
      <h1>Markdown Task Tables</h1>
      <div id="tables-container"></div>
      <button id="add-table-btn" class="add-table">+ ADD NEW TABLE</button>
      <div id="new-table-form" class="new-table-form">
        <h2>Create New Table</h2>
        <input type="text" id="table-title" placeholder="Enter table title" />
        <button id="create-table-btn">Create Table</button>
      </div>
    
      <script>
        const tablesContainer = document.getElementById("tables-container");
        const addTableBtn = document.getElementById("add-table-btn");
        const newTableForm = document.getElementById("new-table-form");
        const tableTitleInput = document.getElementById("table-title");
        const createTableBtn = document.getElementById("create-table-btn");
    
        addTableBtn.addEventListener("click", () => {
          newTableForm.style.display = "block";
        });
    
        createTableBtn.addEventListener("click", () => {
          const title = tableTitleInput.value.trim();
          if (title) {
            fetch("/create_table", {
              method: "POST",
              headers: { "Content-Type": "application/json" },
              body: JSON.stringify({ title }),
            }).then(() => loadTables());
            tableTitleInput.value = "";
            newTableForm.style.display = "none";
          }
        });
    
        function loadTables() {
          fetch("/get_tables")
            .then(res => res.json())
            .then(tables => {
              tablesContainer.innerHTML = "";
              tables.forEach(table => {
                const container = document.createElement("div");
                container.className = "table-container";
    
                const titleDiv = document.createElement("div");
                titleDiv.className = "table-title";
                titleDiv.textContent = table.title;
                container.appendChild(titleDiv);
    
                const tableEl = document.createElement("table");
                const thead = document.createElement("thead");
                const headerRow = document.createElement("tr");
                ["Task", "Status"].forEach(text => {
                  const th = document.createElement("th");
                  th.textContent = text;
                  headerRow.appendChild(th);
                });
                thead.appendChild(headerRow);
                tableEl.appendChild(thead);
    
                const tbody = document.createElement("tbody");
                table.tasks.forEach(task => {
                  const row = document.createElement("tr");
                  const taskCell = document.createElement("td");
                  const taskInput = document.createElement("input");
                  taskInput.type = "text";
                  taskInput.value = task.name;
                  taskInput.className = "task-name";
                  taskCell.appendChild(taskInput);
                  row.appendChild(taskCell);
    
                  const statusCell = document.createElement("td");
                  const checkbox = document.createElement("input");
                  checkbox.type = "checkbox";
                  checkbox.checked = task.done;
                  statusCell.appendChild(checkbox);
                  row.appendChild(statusCell);
                  tbody.appendChild(row);
                });
    
                tableEl.appendChild(tbody);
                container.appendChild(tableEl);
    
                const controls = document.createElement("div");
                controls.className = "controls";
    
                const addRowBtn = document.createElement("button");
                addRowBtn.className = "add-row";
                addRowBtn.textContent = "+ Add Task";
                addRowBtn.addEventListener("click", () => {
                  const row = document.createElement("tr");
                  const taskCell = document.createElement("td");
                  const taskInput = document.createElement("input");
                  taskInput.type = "text";
                  taskInput.className = "task-name";
                  taskCell.appendChild(taskInput);
                  row.appendChild(taskCell);
    
                  const statusCell = document.createElement("td");
                  const checkbox = document.createElement("input");
                  checkbox.type = "checkbox";
                  statusCell.appendChild(checkbox);
                  row.appendChild(statusCell);
                  tbody.appendChild(row);
                });
                controls.appendChild(addRowBtn);
    
                const copyBtn = document.createElement("button");
                copyBtn.className = "copy-md";
                copyBtn.textContent = "Copy as Markdown";
                copyBtn.addEventListener("click", () => {
                  fetch(`/get_table_markdown/${table.id}`)
                    .then(res => res.text())
                    .then(md => navigator.clipboard.writeText(md));
                });
                controls.appendChild(copyBtn);
    
                const saveBtn = document.createElement("button");
                saveBtn.textContent = "Save Changes";
                saveBtn.addEventListener("click", () => {
                  const tasks = [];
                  tbody.querySelectorAll("tr").forEach(row => {
                    const name = row.querySelector(".task-name").value.trim();
                    const done = row.querySelector("input[type='checkbox']").checked;
                    if (name) tasks.push({ name, done });
                  });
                  fetch("/update_table", {
                    method: "POST",
                    headers: { "Content-Type": "application/json" },
                    body: JSON.stringify({ id: table.id, tasks }),
                  });
                });
                controls.appendChild(saveBtn);
    
                container.appendChild(controls);
                tablesContainer.appendChild(container);
              });
            });
        }
    
        loadTables();
      </script>
    </body>
    </html>
    

    ✅ 2. server.py (Backend)

    import json
    import os
    import re
    import uuid
    from http.server import BaseHTTPRequestHandler, HTTPServer
    
    DATA_FILE = "tables.md"
    
    # Initialize the data file if it doesn't exist
    if not os.path.exists(DATA_FILE):
        with open(DATA_FILE, "w") as f:
            f.write("# Task Tables\n\n")
    
    def parse_markdown_tables():
        """Parse the markdown file and extract tables."""
        tables = []
        with open(DATA_FILE, "r") as f:
            content = f.read()
    
        pattern = re.compile(r"## (.*?) id:(\S+)\n\n\|(.*?)\n\|(.*?)\n((?:\|.*\n)*)", re.DOTALL)
        for match in pattern.finditer(content):
            title, table_id, header_row, divider, rows = match.groups()
            tasks = []
            for row in rows.strip().split("\n"):
                cols = [col.strip() for col in row.split("|")[1:-1]]
                if len(cols) >= 2:
                    name = cols[0]
                    done = cols[1].lower() in ("x", "done")
                    tasks.append({"name": name, "done": done})
            tables.append({"id": table_id, "title": title, "tasks": tasks})
        return tables
    
    def save_tables_to_markdown(tables):
        """Save all tables back to the markdown file."""
        lines = ["# Task Tables", ""]
        for table in tables:
            lines.append(f"## {table['title']} id:{table['id']}")
            lines.append("")
            lines.append("| Task | Status |")
            lines.append("| ---- | ------ |")
            for task in table["tasks"]:
                status = "X" if task["done"] else ""
                lines.append(f"| {task['name']} | {status} |")
            lines.append("")
        with open(DATA_FILE, "w") as f:
            f.write("\n".join(lines))
    
    def get_table_markdown(table):
        """Generate markdown for a specific table."""
        md = f"## {table['title']}\n\n"
        md += "| Task | Status |\n"
        md += "| ---- | ------ |\n"
        for task in table["tasks"]:
            status = "X" if task["done"] else ""
            md += f"| {task['name']} | {status} |\n"
        return md
    
    class RequestHandler(BaseHTTPRequestHandler):
        def _set_headers(self, content_type="text/html", status=200):
            self.send_response(status)
            self.send_header("Content-Type", content_type)
            self.end_headers()
    
        def do_GET(self):
            if self.path == "/":
                with open("index.html", "rb") as f:
                    self._set_headers("text/html")
                    self.wfile.write(f.read())
            elif self.path == "/get_tables":
                tables = parse_markdown_tables()
                self._set_headers("application/json")
                self.wfile.write(json.dumps({"tables": tables}).encode())
            elif self.path.startswith("/get_table_markdown/"):
                table_id = self.path.split("/")[-1]
                tables = parse_markdown_tables()
                for table in tables:
                    if table["id"] == table_id:
                        self._set_headers("text/plain")
                        self.wfile.write(get_table_markdown(table).encode())
                        return
                self.send_error(404, "Table not found")
            else:
                self.send_error(404, "Not found")
    
        def do_POST(self):
            if self.path == "/create_table":
                content_length = int(self.headers.get("Content-Length", 0))
                data = json.loads(self.rfile.read(content_length).decode())
                title = data.get("title", "Untitled Table")
                new_id = str(uuid.uuid4())
                tables = parse_markdown_tables()
                tables.append({"id": new_id, "title": title, "tasks": []})
                save_tables_to_markdown(tables)
                self._set_headers("application/json")
                self.wfile.write(json.dumps({"success": True, "id": new_id}).encode())
            elif self.path == "/update_table":
                content_length = int(self.headers.get("Content-Length", 0))
                data = json.loads(self.rfile.read(content_length).decode())
                table_id = data.get("id")
                tasks = data.get("tasks", [])
                tables = parse_markdown_tables()
                for table in tables:
                    if table["id"] == table_id:
                        table["tasks"] = tasks
                        break
                save_tables_to_markdown(tables)
                self._set_headers("application/json")
                self.wfile.write(json.dumps({"success": True}).encode())
            else:
                self.send_error(404, "Not found")
    
    def run(server_class=HTTPServer, handler_class=RequestHandler, port=8000):
        print(f"Starting server on http://localhost:{port}")
        server_address = ("", port)
        httpd = server_class(server_address, handler_class)
        try:
            httpd.serve_forever()
        except KeyboardInterrupt:
            print("\nShutting down server...")
    
    if __name__ == "__main__":
        run()
    

    ✅ 3. tables.md (Initial Template)

    # Task Tables
    

    🚀 How to Use

    1. Save all files in the same folder.
    2. Run the server:
      python3 server.py
      
    3. Open your browser and go to http://localhost:8000.
    4. Click "+ ADD NEW TABLE", enter a title, and click "Create Table".
    5. Add tasks, mark them as done, and click "Save Changes".
    6. Use "Copy as Markdown" to copy the table to your clipboard.

    This solution is fully self-contained, uses no external libraries, and is perfect for local use. All tables are saved in a single .md file, and the UI is intuitive and responsive.

  3. User

    UnicodeEncodeError: 'charmap' codec can't encode character '\u2b1c' in position 211: character maps to

  4. Qwen Assistant

    To resolve the UnicodeEncodeError: 'charmap' codec can't encode character '\u2b1c' error, you need to explicitly set the file encoding to UTF-8 when opening and writing to the tables.md file. This error occurs because your system (likely Windows) is using a different default encoding (e.g., cp1252), which cannot handle Unicode characters like checkboxes (✓, ✅, etc.).


    ✅ Fix: Update File Encoding in server.py

    Modify the file operations in server.py to use encoding="utf-8":

    1. When initializing the tables.md file:

    # Initialize the markdown file if it does not exist
    if not os.path.exists(DATA_FILE):
        with open(DATA_FILE, "w", encoding="utf-8") as f:
            f.write("# Task Tables\n\n")
    

    2. When saving tables to tables.md:

    def save_tables_to_markdown(tables):
        lines = ["# Task Tables", ""]
        for table in tables:
            lines.append(f"## {table['title']} id:{table['id']}")
            lines.append("")
            lines.append("| Task | Status |")
            lines.append("| ---- | ------ |")
            for task in table["tasks"]:
                status = "X" if task["done"] else ""
                lines.append(f"| {task['name']} | {status} |")
            lines.append("")
        with open(DATA_FILE, "w", encoding="utf-8") as f:
            f.write("\n".join(lines))
    

    3. When reading from tables.md:

    def parse_markdown_tables():
        tables = []
        with open(DATA_FILE, "r", encoding="utf-8") as f:
            content = f.read()
        # ... rest of the code ...
    

    🧠 Why This Works

    • The '\u2b1c' character (a checkbox) is a Unicode character.
    • On Windows, the default encoding is often cp1252, which does not support all Unicode characters.
    • By explicitly using encoding="utf-8", you ensure the file is written and read with UTF-8 encoding, which supports all Unicode characters.

    📌 Additional Tips

    1. Ensure your terminal/editor supports UTF-8:

      • On Windows, use PowerShell or Windows Terminal (UTF-8 compatible).
      • In Notepad++, set the encoding to UTF-8 without BOM.
    2. If you're still seeing errors, try this in your script:

      import sys
      import io
      sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
      

    🧪 Test It

    After making the above changes, restart your server and test:

    python3 server.py
    

    Now, the app should handle Unicode characters like checkboxes (✓, ✅) without errors.

    Let me know if you need further help! 😊

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.