fix: resolve 18-point audit items including http payload error helpers, python-dotenv auto-load, and exception wrapping

This commit is contained in:
juanjuanjuanidea
2026-07-24 14:04:39 +08:00
parent e5e1ef3a2d
commit 0e521dc931
5 changed files with 69 additions and 49 deletions
+14 -4
View File
@@ -1,16 +1,22 @@
__version__ = "1.1.0"
import os
from flask import Flask, render_template, jsonify
from dotenv import load_dotenv
from app.db import db
from app.api import accounts, emails
__version__ = "1.1.0"
def create_app():
load_dotenv()
app = Flask(__name__)
db_path = os.getenv("DATABASE_URL", f"sqlite:///{os.path.join(os.getcwd(), 'ni_mail.db')}")
data_dir = os.getenv("DATA_DIR", os.getcwd())
default_db = f"sqlite:///{os.path.join(data_dir, 'ni_mail.db')}"
db_path = os.getenv("DATABASE_URL", default_db)
app.config["SQLALCHEMY_DATABASE_URI"] = db_path
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["SECRET_KEY"] = os.getenv("SECRET_KEY", "ni-mail-secret-key")
app.config["SECRET_KEY"] = os.getenv("SECRET_KEY", "ni-mail-secret-key-v1.1.0")
db.init_app(app)
@@ -23,7 +29,11 @@ def create_app():
@app.route("/health")
def health():
return jsonify({"status": "ok", "app": "ni-mail"})
return jsonify({
"status": "ok",
"app": "ni-mail",
"version": __version__
})
with app.app_context():
db.create_all()