#!/usr/bin/env python # -*- coding: utf-8 -*- from flask import Flask, render_template, jsonify import dataset app = Flask(__name__) # 连接到SQLite数据库 db = dataset.connect('sqlite:///resources/urls.db') @app.route('/') def index(): return render_template('index.html') @app.route('/api/prompts') def get_cards(): # 获取 cards 表中的所有数据 cards = db['cards'].all() print(list(cards)) # 将数据转换为 JSON 格式,并返回 return jsonify(cards=list(cards)) if __name__ == '__main__': app.run(debug=True,host="0.0.0.0",port=5001)