1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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)
|