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