progress count

This commit is contained in:
randogoth 2023-05-22 11:25:46 +03:00
parent 7f1a8e0a6c
commit 361c75c6f7
6 changed files with 53 additions and 31 deletions

View file

@ -18,9 +18,12 @@ app = Flask(__name__)
@app.route("/track", methods = ['GET'])
def track():
if request.method == 'GET' and request.args.get('hash'):
hash = str(request.args.get('hash'))
cat = str(request.args.get('cat'))
ua = str(request.args.get('ua'))
url = str(request.values.get("url") or request.headers.get("Referer"))
if os.path.exists('db.json'):
with open('db.json', 'r') as db:
db = json.loads(db.read())
@ -35,7 +38,7 @@ def track():
visits = list(set(visits))
db.update({
hash : {
'visits' : visits,
cat : visits,
'agent' : ua
}
})
@ -45,7 +48,7 @@ def track():
with open('db.json', 'w+') as dbw:
dbw.write(json.dumps(db, indent=4))
return str(len(db[hash]))
return str(len(db[hash][cat]))
else:
return 'hash missing'