diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2023-02-21 15:18:10 +0100 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2023-02-21 15:18:10 +0100 |
commit | bc053a9b414722990e9d62cce9f32963cfe43096 (patch) | |
tree | fb9c76e79c518ab47bb5b399ab64c53fdcf0e8e9 /www | |
parent | pie -> barh (diff) | |
download | travnik-bc053a9b414722990e9d62cce9f32963cfe43096.tar travnik-bc053a9b414722990e9d62cce9f32963cfe43096.tar.gz travnik-bc053a9b414722990e9d62cce9f32963cfe43096.tar.bz2 travnik-bc053a9b414722990e9d62cce9f32963cfe43096.tar.lz travnik-bc053a9b414722990e9d62cce9f32963cfe43096.tar.xz travnik-bc053a9b414722990e9d62cce9f32963cfe43096.tar.zst travnik-bc053a9b414722990e9d62cce9f32963cfe43096.zip |
Diffstat (limited to 'www')
-rwxr-xr-x | www/app.py | 35 |
1 files changed, 35 insertions, 0 deletions
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) |