multiple changes

This commit is contained in:
www
2021-01-11 18:45:03 +00:00
parent 14ca632137
commit 3d3474a2e1
24 changed files with 3517 additions and 83 deletions

View File

@@ -5,7 +5,7 @@ import re
from flask import redirect, url_for, send_from_directory
from .pth import pth
import bs4
from urllib.parse import urljoin
bp = Blueprint("internfiles", __name__, url_prefix="/internfiles")
@@ -35,9 +35,10 @@ class Folder:
def load_file_and_folder(path: str = ""):
f, directory = (None, None)
path = pth(path)
datapath = pth("/mnt/save/daten")
datapath = pth("./data")
filepath = datapath + path
if not os.path.isdir(datapath):
return None, None
if not str(path) == "" and not (filepath in datapath):
return None, None
@@ -56,14 +57,17 @@ def load_file_and_folder(path: str = ""):
def web(path=""):
f, d = load_file_and_folder(path)
if not f and not d.p == path:
return redirect(url_for("internfiles.web", path=d.p), code=302)
path=urljoin("https://bot.2020.fet.at",url_for(".web", path=d.p))
print(f"url for :{path}")
return redirect(path, code=302)
text = None
print("Accessing internfiles.web path %s"% path)
if f and f.endswith(".txt"):
text = os.path.abspath(f)
with open(os.path.abspath(f), "r", encoding='utf-8') as fh:
text = (fh.read())
text = re.sub("\\n\s*\\n", "<br>", text)
text = re.sub(r"\\n\s*\\n", "<br>", text)
#text=bs4.BeautifulSoup(text).text
elif f:
return send_from_directory(str(f - 1), str(f[-1]))