mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
23 lines
878 B
Python
23 lines
878 B
Python
|
from starlette.requests import Request
|
||
|
from starlette.responses import *
|
||
|
from royalnet.constellation import *
|
||
|
from royalnet.utils import *
|
||
|
from ..tables import *
|
||
|
import uuid
|
||
|
|
||
|
|
||
|
class ApiWikiGetStar(PageStar):
|
||
|
path = "/api/wiki/get/{wiki_page_uuid}"
|
||
|
|
||
|
async def page(self, request: Request) -> JSONResponse:
|
||
|
wiki_page_uuid_str = request.path_params.get("wiki_page_uuid", "")
|
||
|
try:
|
||
|
wiki_page_uuid = uuid.UUID(wiki_page_uuid_str)
|
||
|
except (ValueError, AttributeError, TypeError):
|
||
|
return shoot(400, "Invalid wiki_page_uuid")
|
||
|
async with self.alchemy.session_acm() as session:
|
||
|
wikipage: WikiPage = await asyncify(session.query(self.alchemy.get(WikiPage)).get, wiki_page_uuid)
|
||
|
if wikipage is None:
|
||
|
return shoot(404, "No such page")
|
||
|
return JSONResponse(wikipage.json_full())
|