25 lines
484 B
Python
25 lines
484 B
Python
from flask import Flask, render_template
|
|
import sqlite3
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route('/')
|
|
def index():
|
|
# 连接数据库
|
|
conn = sqlite3.connect('conversation.db')
|
|
c = conn.cursor()
|
|
|
|
# 从数据库中获取数据
|
|
c.execute("SELECT * FROM conversation")
|
|
conversations = c.fetchall()
|
|
|
|
# 关闭数据库连接
|
|
conn.close()
|
|
|
|
return render_template("./index.html", conversations=conversations)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True)
|