Cybrkyd's Git Repositories

notes - commit: 73b7638

commit 73b7638e9136a19423159b20c41bfa2bb9356c54086dfcc58a3047b59b0dc690
author Cybrkyd <git@cybrkyd.com> 2026-06-09 19:03:02 +0100
committer Cybrkyd <git@cybrkyd.com> 2026-06-09 19:03:02 +0100

Commit Message

Removed Export/Import functions

📊 Diffstat

notes.py 76
1 files changed, 0 insertions(+), 76 deletions(-)

Diff

diff --git a/notes.py b/notes.py
index 4caf2f5..859a494 100644
--- a/notes.py
+++ b/notes.py
@@ -221,10 +221,7 @@ textarea:focus {
<button class="link-btn" id="saveBtn">Save Note</button>
<button class="link-btn" id="newBtn">New Note</button>
<button class="link-btn" id="exportBtn">Export as TXT</button>
- <button class="link-btn" id="exportDbBtn">Export NotesDB</button>
- <button class="link-btn" id="importDbBtn">Import NotesDB</button>
</div>
- <input type="file" id="importFile" accept=".json" style="display:none;">
</div>
</div>
@@ -405,47 +402,6 @@ function exportDocument() {
URL.revokeObjectURL(url);
}
-
- async function exportDatabase() {
- try {
- const docs = await apiGet("/api/notes");
- if (!docs.length) { alert("No notes to export"); return; }
- const blob = new Blob([JSON.stringify(docs, null, 2)], { type: "application/json" });
- const url = URL.createObjectURL(blob);
- const a = document.createElement("a");
- a.href = url;
- a.download = `NotesDB-${new Date().toISOString().replace(/[:.]/g, "-")}.json`;
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
- } catch (e) {
- alert("Export failed: " + e.message);
- }
- }
-
-
- async function importDatabase(file) {
- const reader = new FileReader();
- reader.onload = async function(event) {
- try {
- const data = JSON.parse(event.target.result);
- if (!Array.isArray(data)) { alert("Invalid backup file"); return; }
- await apiPost("/api/import", { notes: data });
- currentDocId = null;
- document.getElementById("editor").value = "";
- updateCounts("");
- loadDocuments();
- updateStatus();
- alert("Import complete");
- } catch (e) {
- alert("Import failed: " + e.message);
- }
- };
- reader.readAsText(file);
- }
-
-
function updateCounts(text) {
const characters = text.length;
const words = text.trim().split(/\s+/).filter(Boolean).length;
@@ -471,15 +427,6 @@ document.getElementById("newBtn").onclick = function() {
};
document.getElementById("exportBtn").onclick = exportDocument;
- document.getElementById("exportDbBtn").onclick = exportDatabase;
- document.getElementById("importDbBtn").onclick = function() {
- document.getElementById("importFile").click();
- };
- document.getElementById("importFile").onchange = function(event) {
- const file = event.target.files[0];
- if (file) importDatabase(file);
- };
-
const savedColumn = document.getElementById("savedColumn");
const toggleBtn = document.getElementById("toggleBtn");
@@ -606,27 +553,6 @@ class NotesHandler(http.server.BaseHTTPRequestHandler):
note_id = cur.lastrowid
self._send_json({"id": note_id, "created": created}, 201)
- elif self.path == "/api/import":
- data = self._read_json()
- notes = data.get("notes", [])
- if not isinstance(notes, list):
- self._send_error(400, "notes must be a list")
- return
- with get_db() as conn:
- conn.execute("DELETE FROM notes")
- for note in notes:
- conn.execute(
- "INSERT INTO notes (id, name, content, created) VALUES (?, ?, ?, ?)",
- (
- note.get("id"),
- note.get("name"),
- note.get("content", ""),
- note.get("created", datetime.now().strftime("%d/%m/%Y, %H:%M:%S"))
- )
- )
- conn.commit()
- self._send_json({"imported": len(notes)})
-
else:
self._send_error(404, "Not found")
@@ -671,8 +597,6 @@ class NotesHandler(http.server.BaseHTTPRequestHandler):
self._send_error(404, "Not found")
- # -------
-
if __name__ == "__main__":
init_db()
server = http.server.HTTPServer(("127.0.0.1", PORT), NotesHandler)