Compare commits

..

10 Commits

4 changed files with 13 additions and 8 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.
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, WHOM 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, WHO I FUCKED LAST NIGHT.

View File

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

View File

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

11
run.py
View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
from flask import Flask, request, redirect, url_for, send_from_directory, abort, render_template
from werkzeug import secure_filename
from werkzeug.utils import secure_filename
from threading import Thread, Timer
import logging
import os
@ -45,7 +45,7 @@ def 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.start()
print_log('Thread', 'Cleaner prepared', print_debug)
# Actual function
delete_old()
@ -69,6 +69,7 @@ def error_page(error, code):
def allowed_file(filename):
if config["ALLOW_ALL_FILES"]:
print_log('Main', 'All files permitted, no check done', print_debug)
return True
else:
if config["BLACKLIST"]:
@ -90,6 +91,7 @@ def upload_file():
if file and allowed_file(file.filename):
filename = secure_filename(file.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)
thread1 = Thread(target = db.add_file, args = (filename,))
@ -104,8 +106,10 @@ def upload_file():
try:
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"])
except Exception:
print_log('Web', 'No web reported in form, returned JSON', print_debug)
return json.dumps(data)
else:
print_log('Notice', 'Forbidden file received')
@ -181,9 +185,10 @@ def nginx_error(error):
if config["DELETE_FILES"]:
cleaner_thread()
print_log('Main', 'Launching flask', print_debug)
if __name__ == '__main__':
app.run(
port=config["PORT"],
host=config["HOST"],
debug=config["DEBUG"]
debug=config["EXTENDED_DEBUG"]
)