2026-04-05 07:27:58 +00:00
|
|
|
from flask import Flask, jsonify
|
2025-07-12 11:04:53 +00:00
|
|
|
from src.clover_sqlite.models.questions import Question
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
|
@app.route("/")
|
|
|
|
|
def hello():
|
|
|
|
|
return "Hello World!"
|
|
|
|
|
|
|
|
|
|
@app.route("/list")
|
|
|
|
|
async def list_data():
|
|
|
|
|
return await Question.fetch()
|
|
|
|
|
|
|
|
|
|
@app.route("/init")
|
|
|
|
|
async def init_data():
|
|
|
|
|
if await Question.insert_one("你好", "你好哦"):
|
|
|
|
|
return "success"
|
|
|
|
|
|
|
|
|
|
return "failed"
|
|
|
|
|
|
2026-04-05 07:27:58 +00:00
|
|
|
@app.route("/ping", methods=["GET"])
|
|
|
|
|
def ping():
|
|
|
|
|
return jsonify({"status": "ok", "message": "pong"}), 200
|
|
|
|
|
|
2025-07-12 11:04:53 +00:00
|
|
|
def start_flask():
|
|
|
|
|
print("Flask启动中...")
|
2025-09-04 08:28:48 +00:00
|
|
|
app.run(host='0.0.0.0', port=5001, debug=False, use_reloader=False)
|