Skip to content

Commit 771df57

Browse files
committed
Fix flask 1.x compat again
We have to set up .get etc. *before* importing the things that use it.
1 parent cd5062d commit 771df57

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

sogs/web.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22

33
app = flask.Flask(__name__)
44

5-
from . import logging # noqa: F401, E402
6-
from . import routes # noqa: F401, E402
7-
from . import onion_request # noqa: F401, E402
8-
from . import legacy_routes # noqa: F401, E402
9-
from . import cleanup # noqa: F401, E402
10-
11-
# Monkey-patch app.get/post/etc. for Flask <2 compatibility
5+
# Monkey-patch app.get/post/etc. for Flask <2 compatibility; this has to be before the imports,
6+
# below, because they depend on this existing.
127
if not hasattr(flask.Flask, 'post'):
138

149
def _add_flask_method(name):
@@ -19,3 +14,9 @@ def meth(self, rule: str, **options):
1914

2015
for method in ('get', 'post', 'put', 'delete', 'patch'):
2116
_add_flask_method(method)
17+
18+
from . import logging # noqa: F401, E402
19+
from . import routes # noqa: F401, E402
20+
from . import onion_request # noqa: F401, E402
21+
from . import legacy_routes # noqa: F401, E402
22+
from . import cleanup # noqa: F401, E402

0 commit comments

Comments
 (0)