mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
24 lines
662 B
Python
24 lines
662 B
Python
|
from starlette.requests import Request
|
||
|
from starlette.responses import *
|
||
|
from royalnet.web import *
|
||
|
from royalnet.utils import *
|
||
|
import royalnet.packs.common.tables as cpt
|
||
|
import royalpack.tables as rpt
|
||
|
|
||
|
|
||
|
class ApiKei(PageStar):
|
||
|
path = "/api/kei"
|
||
|
|
||
|
tables = {}
|
||
|
|
||
|
async def _generate(self, request: Request, session) -> typing.Tuple[str, str]:
|
||
|
return "happy", "Ciao!"
|
||
|
|
||
|
async def page(self, request: Request) -> JSONResponse:
|
||
|
async with self.session_acm() as session:
|
||
|
emotion, text = await self._generate(request, session)
|
||
|
return JSONResponse({
|
||
|
"emotion": emotion,
|
||
|
"text": text,
|
||
|
})
|