formatting

This commit is contained in:
Damien Elmes 2020-07-07 13:28:30 +10:00
parent ca24dfddb1
commit 93425be839

View file

@ -9,12 +9,12 @@ import os
import re import re
import sys import sys
import threading import threading
import time
import traceback import traceback
from http import HTTPStatus from http import HTTPStatus
import flask import flask
import flask_cors # type: ignore import flask_cors # type: ignore
import time
from flask import request from flask import request
from waitress.server import create_server from waitress.server import create_server
@ -93,10 +93,7 @@ def allroutes(pathin):
try: try:
directory, path = _redirectWebExports(pathin) directory, path = _redirectWebExports(pathin)
except TypeError: except TypeError:
return flask.make_response( return flask.make_response(f"Invalid path: {pathin}", HTTPStatus.FORBIDDEN,)
f"Invalid path: {pathin}",
HTTPStatus.FORBIDDEN,
)
try: try:
isdir = os.path.isdir(os.path.join(directory, path)) isdir = os.path.isdir(os.path.join(directory, path))
@ -153,10 +150,7 @@ def allroutes(pathin):
return flask.send_file(fullpath, mimetype=mimetype, conditional=True) return flask.send_file(fullpath, mimetype=mimetype, conditional=True)
else: else:
print(f"Not found: {pathin}") print(f"Not found: {pathin}")
return flask.make_response( return flask.make_response(f"Invalid path: {pathin}", HTTPStatus.NOT_FOUND,)
f"Invalid path: {pathin}",
HTTPStatus.NOT_FOUND,
)
except Exception as error: except Exception as error:
if devMode: if devMode:
@ -178,12 +172,12 @@ def _redirectWebExports(path):
# catch /_anki references and rewrite them to web export folder # catch /_anki references and rewrite them to web export folder
targetPath = "_anki/" targetPath = "_anki/"
if path.startswith(targetPath): if path.startswith(targetPath):
return _exportFolder, path[len(targetPath):] return _exportFolder, path[len(targetPath) :]
# catch /_addons references and rewrite them to addons folder # catch /_addons references and rewrite them to addons folder
targetPath = "_addons/" targetPath = "_addons/"
if path.startswith(targetPath): if path.startswith(targetPath):
addonPath = path[len(targetPath):] addonPath = path[len(targetPath) :]
try: try:
addMgr = aqt.mw.addonManager addMgr = aqt.mw.addonManager