expose the list of registered targets to default page
[relay.git/.git] / relay / default.py
1 import aiohttp.web
2 from . import app, CONFIG
3 from .database import DATABASE
4
5 host = CONFIG['ap']['host']
6 note = CONFIG['note']
7 targets = '<br>'.join([target for target in DATABASE.get('relay-list', [])])
8
9 async def default(request):
10     return aiohttp.web.Response(
11         status=200,
12         content_type="text/html",
13         charset="utf-8",
14         text="""
15 <html><head>
16  <title>ActivityPub Relay at {host}</title>
17  <style>
18   p {{ color: #FFFFFF; font-family: monospace, arial; font-size: 100%; }}
19   body {{ background-color: #000000; }}
20   </style>
21 </head>
22 <body>
23 <p>This is an Activity Relay for fediverse instances.</p>
24 <p>{note}</p>
25 <p>For Mastodon instances, you may subscribe to this relay with the address: <a href="https://{host}/inbox">https://{host}/inbox</a></p>
26 <p>For Pleroma and other instances, you may subscribe to this relay with the address: <a href="https://{host}/actor">https://{host}/actor</a></p>
27 <p>To host your own relay, you may download the code at this address: <a href="https://git.pleroma.social/pleroma/relay">https://git.pleroma.social/pleroma/relay</a></p>
28 <br><p>List of registered instances:<br>{targets}</p>
29 </body></html>
30
31 """.format(host=host, note=note,targets=targets))
32
33 app.router.add_get('/', default)