diff options
| author | Fulgen301 <tokmajigeorge@gmail.com> | 2018-09-16 16:58:21 +0200 |
|---|---|---|
| committer | Fulgen301 <tokmajigeorge@gmail.com> | 2018-09-16 16:58:21 +0200 |
| commit | 027139279aa0e83c123ba26139d84505f1d4af90 (patch) | |
| tree | ff9ecd64cab21f2b034288a476870282fb944fa5 /__main__.py | |
| parent | 0184fbb68c8bf1d8d1a123929dfab0497d5236af (diff) | |
| download | parry-027139279aa0e83c123ba26139d84505f1d4af90.tar.gz parry-027139279aa0e83c123ba26139d84505f1d4af90.zip | |
Use sqlalchemy as backend, implement JWT authentication, add uploading, commenting and voting
Diffstat (limited to '__main__.py')
| -rw-r--r-- | __main__.py | 17 |
1 files changed, 13 insertions, 4 deletions
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") |
