multiple changes
This commit is contained in:
@@ -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]))
|
||||
|
||||
Reference in New Issue
Block a user