mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-07-03 15:41:27 +00:00
26 lines
No EOL
625 B
Python
26 lines
No EOL
625 B
Python
from flask import Flask, jsonify
|
|
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"
|
|
|
|
@app.route("/ping", methods=["GET"])
|
|
def ping():
|
|
return jsonify({"status": "ok", "message": "pong"}), 200
|
|
|
|
def start_flask():
|
|
print("Flask启动中...")
|
|
app.run(host='0.0.0.0', port=5001, debug=False, use_reloader=False) |