diff options
| -rw-r--r-- | src/petthecord/server.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/petthecord/server.py b/src/petthecord/server.py index 8c3d8a2..35cbca7 100644 --- a/src/petthecord/server.py +++ b/src/petthecord/server.py @@ -1,6 +1,7 @@ from io import BytesIO +from typing import NoReturn -from aiohttp.web import Application, StreamResponse, get, Request, Response +from aiohttp.web import Application, StreamResponse, get, HTTPFound, Request, Response from discord import NotFound, HTTPException from discord.ext import commands from petpetgif import petpet @@ -11,9 +12,17 @@ class Server(Application): self.client = client super().__init__() - self.add_routes([get("/{uid}", self.root)]) + self.add_routes( + [ + get("/{uid}", self.petpet), + get("/", self.root) + ] + ) - async def root(self, request: Request) -> StreamResponse: + async def root(self, _: Request) -> NoReturn: + raise HTTPFound("https://github.com/nakidai/petthecord") + + async def petpet(self, request: Request) -> StreamResponse: try: uid = int(request.match_info["uid"][:request.match_info["uid"].find('.')]) except ValueError: |