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