add maxkb toggle

This commit is contained in:
2026-04-27 08:57:18 -06:00
parent c2549cf3cc
commit e1af34a986
3 changed files with 32 additions and 6 deletions

11
main.py
View File

@@ -1,4 +1,3 @@
from io import StringIO
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import StreamingResponse
@@ -36,6 +35,16 @@ DATABASE_URL = "sqlite://database.db"
DatabaseService.init_database(app, DATABASE_URL)
@app.get("/maxkb")
async def get_maxkb():
return {"enabled": await DatabaseService.get_maxkb_enabled()}
@app.post("/maxkb")
async def toggle_maxkb():
return {"enabled": await DatabaseService.toggle_maxkb_enabled()}
@app.get("/")
async def get_all_codes() -> dict:
"""获取所有预设代码"""