Add more logging because I'm bored
This commit is contained in:
parent
140265c46d
commit
155dd4ce3f
7
run.py
7
run.py
|
@ -45,7 +45,7 @@ def cleaner_thread():
|
||||||
cleaner = Timer(config["CLEAN_INTERVAL"], cleaner_thread)
|
cleaner = Timer(config["CLEAN_INTERVAL"], cleaner_thread)
|
||||||
cleaner.daemon = True # Daemons will attempt to exit cleanly along with the main process, which we want
|
cleaner.daemon = True # Daemons will attempt to exit cleanly along with the main process, which we want
|
||||||
cleaner.start()
|
cleaner.start()
|
||||||
|
print_log('Thread', 'Cleaner prepared', print_debug)
|
||||||
# Actual function
|
# Actual function
|
||||||
delete_old()
|
delete_old()
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ def error_page(error, code):
|
||||||
|
|
||||||
def allowed_file(filename):
|
def allowed_file(filename):
|
||||||
if config["ALLOW_ALL_FILES"]:
|
if config["ALLOW_ALL_FILES"]:
|
||||||
|
print_log('Main', 'All files permitted, no check done', print_debug)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
if config["BLACKLIST"]:
|
if config["BLACKLIST"]:
|
||||||
|
@ -90,6 +91,7 @@ def upload_file():
|
||||||
if file and allowed_file(file.filename):
|
if file and allowed_file(file.filename):
|
||||||
filename = secure_filename(file.filename)
|
filename = secure_filename(file.filename)
|
||||||
while os.path.exists(os.path.join(config["UPLOAD_FOLDER"], filename)):
|
while os.path.exists(os.path.join(config["UPLOAD_FOLDER"], filename)):
|
||||||
|
print_log('Main', 'File exists, generating new name', print_debug)
|
||||||
filename = str(randint(1000,8999)) + '-' + secure_filename(filename)
|
filename = str(randint(1000,8999)) + '-' + secure_filename(filename)
|
||||||
|
|
||||||
thread1 = Thread(target = db.add_file, args = (filename,))
|
thread1 = Thread(target = db.add_file, args = (filename,))
|
||||||
|
@ -104,8 +106,10 @@ def upload_file():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if request.form["source"] == "web":
|
if request.form["source"] == "web":
|
||||||
|
print_log('Web', 'Returned link page', print_debug)
|
||||||
return render_template('link.html', data=data, page=config["SITE_DATA"])
|
return render_template('link.html', data=data, page=config["SITE_DATA"])
|
||||||
except Exception:
|
except Exception:
|
||||||
|
print_log('Web', 'No web reported in form, returned JSON', print_debug)
|
||||||
return json.dumps(data)
|
return json.dumps(data)
|
||||||
else:
|
else:
|
||||||
print_log('Notice', 'Forbidden file received')
|
print_log('Notice', 'Forbidden file received')
|
||||||
|
@ -181,6 +185,7 @@ def nginx_error(error):
|
||||||
if config["DELETE_FILES"]:
|
if config["DELETE_FILES"]:
|
||||||
cleaner_thread()
|
cleaner_thread()
|
||||||
|
|
||||||
|
print_log('Main', 'Launching flask', print_debug)
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(
|
app.run(
|
||||||
port=config["PORT"],
|
port=config["PORT"],
|
||||||
|
|
Loading…
Reference in New Issue