新增paint页面,暂时放弃api来fetch数据构建页面,预计可能还有大量问题,暂时打算先整理所有的文件

This commit is contained in:
2026-06-19 20:08:22 +00:00
parent abdf1b4258
commit 45bac5e3c3
11 changed files with 147 additions and 67 deletions

View File

@@ -4,6 +4,15 @@ import os
index_bp = Blueprint('/', __name__)
db_path = "/var/open-ww3-project-ww3-tw/databases/sqlite/owp.db"
def get_paint_db_conn():
conn = sqlite3.connect(db_path)
conn.row_factory = sqlite3.Row
return conn
@index_bp.route('/')
def repage():
return redirect(url_for('blog.home'))
@@ -14,4 +23,23 @@ def mirrors():
@index_bp.route('/greet/<name>/')
def greet(name):
return f'Hello, {name}!'
return f'Hello, {name}!'
@index_bp.route('/paint/')
def paint_home():
conn = get_paint_db_conn()
select_sql = "SELECT * FROM paint;"
data = conn.execute(select_sql).fetchall()
conn.close()
# 展示图片
img_url = "https://open-ww3-project.ww3.tw/blog/folders/paint/new/"
# 查询tags和class
db_cursor = sqlite3.connect(db_path).cursor()
tags_sql = "SELECT DISTINCT tags FROM paint;"
class_sql = "SELECT DISTINCT class FROM paint;"
for class_data in db_cursor.execute(class_sql).fetchall():
for tags_data in db_cursor.execute(tags_sql).fetchall():
return render_template('paint/home.html', data = data, tags_data = tags_data[0], class_data = class_data[0], img_url = img_url)