mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 01:23:55 +08:00
update:优化页面样式
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import logging
|
||||
from aiohttp import web
|
||||
from manager.api.auth import verify_token
|
||||
from manager.api.response import response_unauthorized, response_success, response_error
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PromptHandler:
|
||||
class PromptApi:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
||||
async def get_prompt(self, request):
|
||||
if not await verify_token(self.config, request):
|
||||
return web.json_response({'error': 'Unauthorized'}, status=401)
|
||||
return response_unauthorized()
|
||||
|
||||
return web.json_response({
|
||||
'prompt': self.config['prompt'],
|
||||
@@ -20,17 +21,16 @@ class PromptHandler:
|
||||
|
||||
async def update_prompt(self, request):
|
||||
if not await verify_token(self.config, request):
|
||||
return web.json_response({'error': 'Unauthorized'}, status=401)
|
||||
return response_unauthorized()
|
||||
|
||||
try:
|
||||
data = await request.json()
|
||||
if 'prompt' not in data:
|
||||
return web.json_response({'error': 'Missing prompt field'}, status=400)
|
||||
return response_success()
|
||||
|
||||
# 通过config参数回传修改能力
|
||||
self.config['prompt'] = data['prompt']
|
||||
return web.json_response({'success': True}, headers={'Access-Control-Allow-Origin': '*'})
|
||||
return response_success()
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to update prompt: {e}")
|
||||
return web.json_response({'error': str(e)}, status=500)
|
||||
return response_error(str(e))
|
||||
|
||||
Reference in New Issue
Block a user