def getChat(sid, cid, page, lang, profile): session = gs(sid, gu(cid)) import parsers t, i, p = parsers.html(session.lastManfredAnswer, session.actual_image, session.actual_page) return { "text": t, "image": i, "page": p }
def chall(ctf, chall): writeups = load_writeups() if ctf not in writeups: flask.abort(404) if chall not in writeups[ctf]["writeups"]: flask.abort(404) chall_data = writeups[ctf]["writeups"][chall] if "type" in chall_data: data_type = chall_data["type"] if data_type in parsers.valid_content_types: writeup_type = data_type else: writeup_type = "unknown" else: writeup_type = "unknown" res = chall_data["resource"] if writeup_type == "unknown": raise Exception(f"Unknown writeup type for {ctf}/{chall}") elif writeup_type == "youtube": content = parsers.youtube(res) elif writeup_type == "html": content = parsers.html(open("content/" + res, encoding="utf8", errors="ignore").read()) elif writeup_type == "pdf": content = parsers.pdf(url_root() + "content/" + res) breadcrumb = Breadcrumb() breadcrumb.add(writeups[ctf]["name"], "../") breadcrumb.add(chall_data["name"], "") return render_template("chall.html", { "ctfName": writeups[ctf]["name"], "challData": chall_data, "challContent": content, "breadcrumb": breadcrumb, "urlPath": f"{ctf}/{chall}", **({"tags": chall_data["tags"]} if "tags" in chall_data else {}) })
def prepareHtml(self): import parsers x = parsers.html(self) x.feed(self.text) x.close()