From bc053a9b414722990e9d62cce9f32963cfe43096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 21 Feb 2023 15:18:10 +0100 Subject: =?UTF-8?q?nekon=C4=8Dano,=20za=C4=8Denjam=20webapp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/app.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 www/app.py (limited to 'www') diff --git a/www/app.py b/www/app.py new file mode 100755 index 0000000..1ba6af7 --- /dev/null +++ b/www/app.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +from re import search, IGNORECASE +from time import monotonic +from flask import Flask, render_template, escape, request +from sys import argv, path +from os import getpid +from psutil import Process +from urllib.parse import quote +from datetime import datetime +from locale import setlocale, LC_ALL +path.append(".") +from travnik import glob, Type +setlocale(LC_ALL, "") +app = Flask("travnik") +startuptime = -1 +zagon = datetime.now() +def mno(quantity, types): + if quantity % 100 == 1: + return quantity[1] + if quantity % 100 == 2: + return quantity[2] + if quantity % 100 == 3: + return quantity[3] + return quantity[0] +@app.route("/") +def index(): + return render_template("index.html") +if __name__ == "__main__": + print("zaganjam travnik", argv[0], "... zagon traja dolgo časa (~5 min za ~40k torrentov. za delovanje je potrebnih ~300 MiB RAM RES za ~40k torrentov. sharding je WIP.") + start = monotonic() + torrents = {} + print("zagon uspešen. v", monotonic()-start, "sem indeksiral", len(torrents), "torrentov") + app.jinja_env.globals.update(mno=mno, zagontekst=zagon.strftime("%c"), torrentov=len(torrents)) + app.jinja_env.add_extension('jinja2.ext.loopcontrols') + app.run(host="::", port=8080, debug=True) -- cgit v1.2.3