跟着麦叔学flask,感谢b站麦叔

This commit is contained in:
2025-12-21 02:38:00 +08:00
parent 582f8a9234
commit 7e44fe8a2a
20 changed files with 690 additions and 0 deletions

29
blueprint/blog_views.py Executable file
View File

@@ -0,0 +1,29 @@
from flask import Blueprint, render_template
from database import get_owp_db
import os
blog_bp = Blueprint('blog', __name__)
@blog_bp.route('/')
def home():
db = get_owp_db()
return render_template('home.html')
@blog_bp.route('/about/')
def about():
return render_template('about.html')
pass
@blog_bp.route('/db_test/')
def test_db():
db = get_owp_db()
try:
cur = db.execute('SELECT sqlite_version();')
ver = cur.fetchone()[0]
return f"数据库连接成功SQLite 版本是: {ver}"
except Exception as e:
return f"连接失败: {str(e)}"