summaryrefslogtreecommitdiffstats
path: root/www
diff options
context:
space:
mode:
Diffstat (limited to 'www')
-rwxr-xr-xwww/app.py35
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)