flask
This commit is contained in:
parent
23948442cb
commit
12e3fe43d2
2 changed files with 1 additions and 38 deletions
|
|
@ -36,4 +36,4 @@ def track():
|
||||||
else:
|
else:
|
||||||
return 'hash missing'
|
return 'hash missing'
|
||||||
|
|
||||||
app.run()
|
app.run(port=8001)
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
#!/usr/bin/python3
|
|
||||||
print("Content-type:text/html\r\n\r\n")
|
|
||||||
import cgi
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
|
|
||||||
args = cgi.FieldStorage()
|
|
||||||
|
|
||||||
def track():
|
|
||||||
if args['hash']:
|
|
||||||
hash = str(args['hash'])
|
|
||||||
ua = str(args['ua'])
|
|
||||||
url = str(args['url'] or os.getenv('HTTP_REFERER'))
|
|
||||||
if os.path.exists('db.json'):
|
|
||||||
with open('db.json', 'r') as db:
|
|
||||||
db = json.loads(db.read())
|
|
||||||
else:
|
|
||||||
db = {}
|
|
||||||
if hash in db.keys():
|
|
||||||
visits = db[hash]['visits']
|
|
||||||
else:
|
|
||||||
visits = list()
|
|
||||||
|
|
||||||
visits.append(url)
|
|
||||||
visits = list(set(visits))
|
|
||||||
db.update({
|
|
||||||
hash : {
|
|
||||||
'visits' : visits,
|
|
||||||
'agent' : ua
|
|
||||||
}
|
|
||||||
})
|
|
||||||
with open('db.json', 'w+') as dbw:
|
|
||||||
dbw.write(json.dumps(db, indent=4))
|
|
||||||
|
|
||||||
print(str(len(db[hash])))
|
|
||||||
else:
|
|
||||||
print('hash missing')
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue