1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00
royalnet/keipack/stars/api_kei.py

24 lines
662 B
Python
Raw Normal View History

2019-11-11 12:40:26 +00:00
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,
})