1
- __version__ = "1.1"
1
+ __version__ = "1.1.1 "
2
2
3
3
import os
4
4
5
5
from motor .motor_asyncio import AsyncIOMotorClient
6
6
from sanic import Sanic , response
7
- from sanic .exceptions import abort , NotFound
7
+ from sanic .exceptions import NotFound
8
8
from jinja2 import Environment , FileSystemLoader
9
9
10
10
from core .models import LogEntry
19
19
if prefix == "NONE" :
20
20
prefix = ""
21
21
22
- app = Sanic (__name__ )
22
+ MONGO_URI = os .getenv ("MONGO_URI" )
23
+ if not MONGO_URI :
24
+ MONGO_URI = os .environ ['CONNECTION_URI' ]
23
25
26
+ app = Sanic (__name__ )
24
27
app .static ("/static" , "./static" )
25
28
26
29
jinja_env = Environment (loader = FileSystemLoader ("templates" ))
@@ -36,7 +39,7 @@ def render_template(name, *args, **kwargs):
36
39
37
40
@app .listener ("before_server_start" )
38
41
async def init (app , loop ):
39
- app .ctx .db = AsyncIOMotorClient (os . getenv ( " MONGO_URI" ) ).modmail_bot
42
+ app .ctx .db = AsyncIOMotorClient (MONGO_URI ).modmail_bot
40
43
41
44
42
45
@app .exception (NotFound )
@@ -55,7 +58,7 @@ async def get_raw_logs_file(request, key):
55
58
document = await app .ctx .db .logs .find_one ({"key" : key })
56
59
57
60
if document is None :
58
- abort ( 404 )
61
+ raise NotFound
59
62
60
63
log_entry = LogEntry (app , document )
61
64
@@ -68,7 +71,7 @@ async def get_logs_file(request, key):
68
71
document = await app .ctx .db .logs .find_one ({"key" : key })
69
72
70
73
if document is None :
71
- abort ( 404 )
74
+ raise NotFound
72
75
73
76
log_entry = LogEntry (app , document )
74
77
0 commit comments