Compare commits

..

No commits in common. "7f6c199ce3a1c7d0cd922af861dd70d297ac0fae" and "95bb5e18b06f1f67b36d190652760af59c54be86" have entirely different histories.

4 changed files with 8 additions and 13 deletions

View File

@ -7,4 +7,4 @@ D: IMMEDIATELY INSTALL GENTOO.
E: SEEK OUT THE DWELLING OF RICHARD M. STALLMAN (RICHARD GNU/MARX STALLMAN (RMS)) AND SECRETELY PISS IN HIS BEARD. E: SEEK OUT THE DWELLING OF RICHARD M. STALLMAN (RICHARD GNU/MARX STALLMAN (RMS)) AND SECRETELY PISS IN HIS BEARD.
F: IF YOU ARE SNOOP DOGG YOU ARE EXEMPT FROM THE ABOVE TERMS. F: IF YOU ARE SNOOP DOGG YOU ARE EXEMPT FROM THE ABOVE TERMS.
REDISTRIBUTION, COPYING, MODIFYING, REVERSE-ENGINEERING, LOOKING, GLANCING, PEEKING, SMELLING, AND OTHERWISE INTERACTING WITH THE FOLLOWING CODE IS PROHIBITED AND IS PUNISHABLE BY YOUR MOTHER, WHO I FUCKED LAST NIGHT. REDISTRIBUTION, COPYING, MODIFYING, REVERSE-ENGINEERING, LOOKING, GLANCING, PEEKING, SMELLING, AND OTHERWISE INTERACTING WITH THE FOLLOWING CODE IS PROHIBITED AND IS PUNISHABLE BY YOUR MOTHER, WHOM I FUCKED LAST NIGHT.

View File

@ -13,10 +13,10 @@ config["HOST"] = "127.0.0.1"
config["DOMAIN"] = "http://example.com" config["DOMAIN"] = "http://example.com"
config["PORT"] = 8282 config["PORT"] = 8282
# Will output more logging data from QuadFile's logger # Disable this for production use
config["DEBUG"] = False config["DEBUG"] = False
# Extended Debug will enable flask debugging. Keep this off for production use # Extended debug will add extra debug output that's not normally provided by flask
config["EXTENDED_DEBUG"] = False config["EXTENDED_DEBUG"] = False
# Single user authentication, leave blank to disable authentication # Single user authentication, leave blank to disable authentication
@ -39,5 +39,5 @@ config["CLEAN_INTERVAL"] = 120
# Site info displayed to the user # Site info displayed to the user
config["SITE_DATA"] = { config["SITE_DATA"] = {
"title": "QuadFile", "title": "QuadFile",
"size": "100 MiB" # This is only for display, please limit filesize using your web server "size": "100 MiB" # This is only for display, please limit filesizes using your web server
} }

View File

@ -1 +1 @@
flask==0.12.2 flask==0.10.1

11
run.py
View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from flask import Flask, request, redirect, url_for, send_from_directory, abort, render_template from flask import Flask, request, redirect, url_for, send_from_directory, abort, render_template
from werkzeug.utils import secure_filename from werkzeug import secure_filename
from threading import Thread, Timer from threading import Thread, Timer
import logging import logging
import os import os
@ -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,7 +69,6 @@ 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"]:
@ -91,7 +90,6 @@ 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,))
@ -106,10 +104,8 @@ def upload_file():
try: try:
if request.form["source"] == "web": if request.form["source"] == "web":
print_log('Web', 'Returned link page for "' + filename + '"', 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')
@ -185,10 +181,9 @@ 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"],
host=config["HOST"], host=config["HOST"],
debug=config["EXTENDED_DEBUG"] debug=config["DEBUG"]
) )