~sircmpwn/lists.sr.ht

lists.sr.ht/listssrht/app.py -rw-r--r-- 1.3 KiB View raw
bbaf8ed2Drew DeVault Deliver list deletion webhook via UI 3 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from listssrht.filters import diffstat, format_body, post_address
from listssrht.oauth import ListsOAuthService
from srht.config import cfg
from srht.database import DbSession
from srht.flask import SrhtFlask
from urllib.parse import quote

db = DbSession(cfg("lists.sr.ht", "connection-string"))
db.init()

class ListsApp(SrhtFlask):
    def __init__(self):
        super().__init__("lists.sr.ht", __name__,
                oauth_service=ListsOAuthService())

        self.url_map.strict_slashes = False

        from listssrht.blueprints.api import register_api
        from listssrht.blueprints.archives import archives
        from listssrht.blueprints.patches import patches
        from listssrht.blueprints.settings import settings
        from listssrht.blueprints.user import user

        register_api(self)
        self.register_blueprint(archives)
        self.register_blueprint(patches)
        self.register_blueprint(settings)
        self.register_blueprint(user)

        @self.context_processor
        def inject():
            from listssrht.types import ListAccess
            return {
                "diffstat": diffstat,
                "format_body": format_body,
                "post_address": post_address,
                "quote": quote,
                "ListAccess": ListAccess,
            }

app = ListsApp()