mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-05 05:16:03 +00:00
feat(settings): json 编辑器
This commit is contained in:
@@ -63,11 +63,6 @@ class RouterGroup(abc.ABC):
|
||||
return decorator
|
||||
|
||||
def _cors(self, response: quart.Response) -> quart.Response:
|
||||
# Quart-Cors 似乎很久没维护了,所以自己写
|
||||
response.headers['Access-Control-Allow-Origin'] = '*'
|
||||
response.headers['Access-Control-Allow-Headers'] = '*'
|
||||
response.headers['Access-Control-Allow-Methods'] = '*'
|
||||
response.headers['Access-Control-Allow-Credentials'] = 'true'
|
||||
return response
|
||||
|
||||
def success(self, data: typing.Any = None) -> quart.Response:
|
||||
|
||||
@@ -39,3 +39,12 @@ class SettingsRouterGroup(group.RouterGroup):
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@self.route('/<manager_name>/data', methods=['PUT'])
|
||||
async def _(manager_name: str) -> str:
|
||||
data = await quart.request.json
|
||||
manager = self.ap.settings_mgr.get_manager(manager_name)
|
||||
manager.data = data['data']
|
||||
return self.success(data={
|
||||
"data": manager.data
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
|
||||
import quart
|
||||
import quart_cors
|
||||
|
||||
from ....core import app
|
||||
from .groups import logs, system, settings
|
||||
@@ -18,6 +19,7 @@ class HTTPController:
|
||||
def __init__(self, ap: app.Application) -> None:
|
||||
self.ap = ap
|
||||
self.quart_app = quart.Quart(__name__)
|
||||
quart_cors.cors(self.quart_app, allow_origin='*')
|
||||
|
||||
async def initialize(self) -> None:
|
||||
await self.register_routes()
|
||||
|
||||
Reference in New Issue
Block a user