diff --git a/main.py b/main.py index 4c0c135f61696bcf42c375ca5ab62aa5b105afc8..ee07b023e5a900314a759875aaa8b05f9c4deb5d 100644 --- a/main.py +++ b/main.py @@ -1 +1,25 @@ -print('欢迎来到 InsCode') \ No newline at end of file +#!/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) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5dba0c0907b551ec7d6d2a691edcd8101a5af7d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +dataset \ No newline at end of file diff --git a/resources/urls.db b/resources/urls.db new file mode 100644 index 0000000000000000000000000000000000000000..8e763312608e343f2bfb5ce9bad4ffe9e0007770 Binary files /dev/null and b/resources/urls.db differ diff --git a/resources/urls.db-shm b/resources/urls.db-shm new file mode 100644 index 0000000000000000000000000000000000000000..100cd60c3ce282a88127030ed720f717de763440 Binary files /dev/null and b/resources/urls.db-shm differ diff --git a/resources/urls.db-wal b/resources/urls.db-wal new file mode 100644 index 0000000000000000000000000000000000000000..7e1b35219e92a5bc750f2997585634c486b00eb6 Binary files /dev/null and b/resources/urls.db-wal differ diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..f74dced4fb2931594dfadcd7e74e525e9411285e --- /dev/null +++ b/templates/index.html @@ -0,0 +1,198 @@ + + + +
+ +