2026第一次上传

This commit is contained in:
2026-01-04 15:00:40 +08:00
parent 8373794f11
commit 24dc04287e
9 changed files with 130 additions and 122 deletions

View File

@@ -10,6 +10,10 @@ def get_owp_db_conn():
conn.row_factory = sqlite3.Row
return conn
def get_message_db_conn():
conn = sqlite3.connect('/var/open-ww3-project-ww3-tw/databases/sqlite/message.db')
conn.row_factory = sqlite3.Row
return conn
blog_bp = Blueprint('blog', __name__)
@@ -43,11 +47,13 @@ def posts_list():
@blog_bp.route('/posts/<int:posts_id>/')
def show_posts_id(posts_id):
conn = get_owp_db_conn()
conn_message = get_message_db_conn()
sql_posts = "SELECT * FROM posts WHERE status = 1 AND id = ?"
sql_message = "SELECT * FROM messages WHERE posts_id = ?"
posts = conn.execute(sql_posts, (posts_id,)).fetchone()
message = conn.execute(sql_message, (posts_id,)).fetchall()
sql_message = "SELECT * FROM messages WHERE posts_id = ?"
message = conn_message.execute(sql_message, (posts_id,)).fetchall()
conn.close()
conn_message.close()
if posts is None:
return f'未找到该文章{posts_id}<title>未找到该文章{posts_id}</title>', 404
return render_template('blog/posts.html', posts=posts, message=message[::-1])
@@ -110,4 +116,8 @@ def upload():
return '上传成功<meta http-equiv="refresh" content="1.2;url=https://ww3.tw/blog/upload/">'
img_files = '/var/open-ww3-project-ww3-tw/static/upload/img/'
images = [img for img in os.listdir(img_files) if img.endswith(('.png', '.jpg', '.jpeg', '.gif'))]
return render_template('blog/upload.html', images=images)
return render_template('blog/upload.html', images=images)
@blog_bp.route('/message/')
def messages():
return render_template('message/home.html')

View File

@@ -58,6 +58,7 @@ def new():
@study_bp.route('/posts/<int:posts_id>/edit', methods=('GET', 'POST'))
def edit_posts_id(posts_id):
posts = get_posts(posts_id)
if request.method == "POST":
title = request.form['title']
content = request.form['content']