Browse Source

修复页面更新问题

DIng 2 months ago
parent
commit
b477a86d4b
2 changed files with 2 additions and 7 deletions
  1. BIN
      api/SoilAcidification.db
  2. 2 7
      api/app/frontend.py

BIN
api/SoilAcidification.db


+ 2 - 7
api/app/frontend.py

@@ -20,11 +20,6 @@ logger = logging.getLogger(__name__)
 bp = Blueprint('frontend', __name__)
 
 
-# 封装数据库连接函数
-def get_db_connection():
-    return sqlite3.connect('software_intro.db')
-
-
 # 密码加密
 def hash_password(password):
     return generate_password_hash(password)
@@ -687,7 +682,7 @@ def logout_user():
 @bp.route('/software-intro/<int:id>', methods=['GET'])
 def get_software_intro(id):
     try:
-        conn = get_db_connection()
+        conn = get_db()
         cursor = conn.cursor()
         cursor.execute('SELECT title, intro FROM software_intro WHERE id = ?', (id,))
         result = cursor.fetchone()
@@ -713,7 +708,7 @@ def update_software_intro(id):
         title = data.get('title')
         intro = data.get('intro')
 
-        conn = get_db_connection()
+        conn = get_db()
         cursor = conn.cursor()
         cursor.execute('UPDATE software_intro SET title =?, intro =? WHERE id = ?', (title, intro, id))
         conn.commit()