This commit is contained in:
randogoth 2025-09-27 13:55:46 +03:00
parent 41045fdf3a
commit cc56dec270
3 changed files with 5 additions and 10 deletions

View file

@ -29,10 +29,6 @@ RUN adduser --disabled-password --gecos "" appuser \
USER appuser USER appuser
# Default cache dir (override with TEXTS_CACHE_DIR env if you want)
ENV DB_DIR=/usr/src/app/db
RUN mkdir -p "$DB_DIR"
# Expose the service port # Expose the service port
EXPOSE 5000 EXPOSE 5000

View file

@ -24,8 +24,8 @@ def track():
ua = str(request.args.get('ua')) ua = str(request.args.get('ua'))
url = str(request.values.get("url") or request.headers.get("Referer")) url = str(request.values.get("url") or request.headers.get("Referer"))
if os.path.exists('db/db.json'): if os.path.exists('db.json'):
with open('db/db.json', 'r') as db: with open('db.json', 'r') as db:
db = json.loads(db.read()) db = json.loads(db.read())
else: else:
db = {} db = {}
@ -45,7 +45,7 @@ def track():
send_msg(f'User <{hash}> visited { url } on { ua } ({ str(len(db[hash][cat])) })') send_msg(f'User <{hash}> visited { url } on { ua } ({ str(len(db[hash][cat])) })')
with open('db/db.json', 'w+') as dbw: with open('db.json', 'w+') as dbw:
dbw.write(json.dumps(db, indent=4)) dbw.write(json.dumps(db, indent=4))
return str(len(db[hash][cat])) return str(len(db[hash][cat]))

View file

@ -1,11 +1,10 @@
services: services:
wordonaut: tagbot:
build: . build: .
container_name: tagbot
ports: ports:
- "8001:5000" - "8001:5000"
environment: environment:
- FLASK_APP=wordonaut.py - FLASK_APP=db.py
- FLASK_RUN_HOST=0.0.0.0 - FLASK_RUN_HOST=0.0.0.0
volumes: volumes:
- .:/usr/src/app - .:/usr/src/app