Compare commits
10 Commits
95bb5e18b0
...
7f6c199ce3
Author | SHA1 | Date |
---|---|---|
Quad | 7f6c199ce3 | |
Quad | 03d21bb875 | |
wizard | 1e3b6b091b | |
Dominik V. Salonen | 79044d9902 | |
Dominik V. Salonen | 01b19333ba | |
Dominik V. Salonen | d2acfd264b | |
Dominik V. Salonen | d5a2a2a82e | |
Dominik V. Salonen | 155dd4ce3f | |
Dominik V. Salonen | 140265c46d | |
Dominik V. Salonen | 1c80a2bde9 |
|
@ -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, 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.
|
|
@ -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
|
||||||
|
|
||||||
# Disable this for production use
|
# Will output more logging data from QuadFile's logger
|
||||||
config["DEBUG"] = False
|
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
|
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 filesizes using your web server
|
"size": "100 MiB" # This is only for display, please limit filesize using your web server
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
flask==0.10.1
|
flask==0.12.2
|
||||||
|
|
11
run.py
11
run.py
|
@ -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 import secure_filename
|
from werkzeug.utils 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,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 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')
|
||||||
|
@ -181,9 +185,10 @@ 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["DEBUG"]
|
debug=config["EXTENDED_DEBUG"]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue