From 027139279aa0e83c123ba26139d84505f1d4af90 Mon Sep 17 00:00:00 2001 From: Fulgen301 Date: Sun, 16 Sep 2018 16:58:21 +0200 Subject: Use sqlalchemy as backend, implement JWT authentication, add uploading, commenting and voting --- __main__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to '__main__.py') diff --git a/__main__.py b/__main__.py index f46e94c..95b78ab 100644 --- a/__main__.py +++ b/__main__.py @@ -15,6 +15,8 @@ from .helpers import * from .handlers import * from .routes import * +import time +sys.tracebacklimit = 1000 @route("/api") def get_root(): @@ -23,10 +25,17 @@ def get_root(): if __name__ == "__main__": def loadEntries(): for handler in [CC(), CCAN()]: - for entry in handler.process(): - database["entries"][entry["id"]] = entry - saveJSON(database, "database.json") + handler.process() + + def checkForUnownedFiles(): + while True: + session = DBSession() + for file in session.query(File).filter_by(upload=None): + if not file.upload and file.date - datetime.now() > 5 * 60: + session.delete(file) + _unlink_file(file) + time.sleep(600) threading.Thread(target=loadEntries, daemon=True).start() + threading.Thread(target=checkForUnownedFiles, daemon=True).start() run(host='0.0.0.0', port=9621, debug=True) - saveJSON(database, "database.json") -- cgit v1.2.3-54-g00ecf