from tools import * from AppBridge import * from Utils.Config import * from Utils.Lib import * import openai from collections import defaultdict Invite = flask.Blueprint("Invite", __name__, url_prefix='/', subdomain = "invite", static_folder = JoinPath(FlaskTempLate, "Invite"), template_folder = TempLate, static_url_path="/") ChatHistory: list = [] @Invite.route("/") def InviteElseHtml(file: str): if os.path.isfile(JoinPath(TempLate, "Invite", file)): if file.split(".")[-1].lower() == "html": return ProcessTemplate("Invite/"+file) return openr(JoinPath(TempLate,file), "2") else: flask.abort(404) @Invite.route("/") @Invite.route("/index.html") def InviteIndex(): return ProcessTemplate("/Invite/index.html") @Invite.after_request def InviteAfterIndex(r: flask.Response): if os.path.isfile(JoinPath(FlaskTempLate, "Invite", flask.request.path[1:])) and flask.request.path.split(".")[-1].lower() == "html" and ".".join(flask.request.path.split(".")[:-1]).count("/") != 1: return flask.make_response(ProcessTemplate("Invite/" + flask.request.path[1:], DefaultUse = False)) if r.status_code != 404: return r if os.path.isfile(JoinPath(FlaskTempLate, "Invite", flask.request.path[1:], "index.html")): return flask.make_response(ProcessTemplate("Invite/" + flask.request.path[1:] + "/index.html")) return r