add multiple channel index support

This commit is contained in:
odysseusmax
2020-08-12 10:39:29 +00:00
parent 81679a37c0
commit da02bad347
9 changed files with 87 additions and 32 deletions

View File

@ -1,15 +1,22 @@
from aiohttp import web
from config import chat_ids
def setup_routes(app, handler):
h = handler
app.add_routes(
[
web.get('/', h.index, name='index'),
web.get(r"/{id:\d+}/view", h.info, name='info'),
web.get(r"/{id:\d+}/download", h.download_get),
web.head(r"/{id:\d+}/download", h.download_head),
web.get(r"/{id:\d+}/thumbnail", h.thumbnail_get),
web.head(r"/{id:\d+}/thumbnail", h.thumbnail_head),
routes = [
web.get('/', h.home, name='home')
]
for chat_id in chat_ids:
p = f"/{chat_id}"
r = [
web.get(p, h.index),
web.get(p + r"/{id:\d+}/view", h.info),
web.get(p + r"/{id:\d+}/download", h.download_get),
web.head(p + r"/{id:\d+}/download", h.download_head),
web.get(p + r"/{id:\d+}/thumbnail", h.thumbnail_get),
web.head(p + r"/{id:\d+}/thumbnail", h.thumbnail_head),
]
)
routes += r
app.add_routes(routes)