add register, login and main page with basic functionality

This commit is contained in:
2026-02-24 17:07:18 +01:00
parent f5ac44886b
commit 81ca96ed77
9 changed files with 162 additions and 3 deletions
+35
View File
@@ -0,0 +1,35 @@
import sqlite3
from flask import g
DATABASE = 'sqlite.db'
def get_db():
if 'db' not in g:
g.db = sqlite3.connect(DATABASE)
g.db.row_factory = sqlite3.Row
return g.db
def close_db(e=None):
db = g.pop('db', None)
if db is not None:
db.close()
def init_db(app):
with app.app_context():
db = get_db()
db.execute("PRAGMA journal_mode=WAL;")
db.execute("PRAGMA foreign_keys=ON;")
# create inital tables
db.execute("""
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,username TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
"""
)
db.commit()