manage_uploads
This commit is contained in:
parent
62d8195705
commit
62653d106b
25
fileHost.py
25
fileHost.py
|
@ -52,6 +52,7 @@ app = Flask(__name__)
|
||||||
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||||
app.config['MAX_CONTENT_LENGTH'] = 128 * 1024 * 1024
|
app.config['MAX_CONTENT_LENGTH'] = 128 * 1024 * 1024
|
||||||
app.config["UPLOAD_DIR"] = "/usr/local/www/html/up"
|
app.config["UPLOAD_DIR"] = "/usr/local/www/html/up"
|
||||||
|
app.config["UPLOAD_URL"] = "https://steelbea.me/up/"
|
||||||
app.config["DB_NAME"] = "fileHost.db"
|
app.config["DB_NAME"] = "fileHost.db"
|
||||||
app.config["DB_LOCK"] = threading.Lock()
|
app.config["DB_LOCK"] = threading.Lock()
|
||||||
|
|
||||||
|
@ -247,6 +248,24 @@ def login():
|
||||||
abort(401)
|
abort(401)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/manage_uploads", methods=["POST", "GET"])
|
||||||
|
def manage_uploads():
|
||||||
|
"""
|
||||||
|
Allows the user to view and/or delete uploads they've made.
|
||||||
|
"""
|
||||||
|
username = session.get("username")
|
||||||
|
if not verify_username(username):
|
||||||
|
abort(401)
|
||||||
|
|
||||||
|
uploads = db_execute(
|
||||||
|
"SELECT filename, uploaded_date FROM uploads WHERE uploaded_by = ?",
|
||||||
|
(username,)).fetchall()
|
||||||
|
|
||||||
|
if request.method == "GET":
|
||||||
|
return render_template("manage_uploads.html", uploads=uploads,
|
||||||
|
app_url=app.config.get("APP_URL"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/", methods=["POST", "GET"])
|
@app.route("/", methods=["POST", "GET"])
|
||||||
def index():
|
def index():
|
||||||
"""
|
"""
|
||||||
|
@ -281,9 +300,7 @@ def index():
|
||||||
db_execute("INSERT INTO uploads (filename, uploaded_by) VALUES (?,?)",
|
db_execute("INSERT INTO uploads (filename, uploaded_by) VALUES (?,?)",
|
||||||
(fname, username))
|
(fname, username))
|
||||||
|
|
||||||
#TODO: make this not hardcoded
|
url = app.config.get("UPLOAD_URL") + fname
|
||||||
# url = request.url_root + "up/" + fname
|
|
||||||
url = "https://steelbea.me/up/" + fname
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
|
@ -300,9 +317,9 @@ def get_rand_chars(n):
|
||||||
|
|
||||||
|
|
||||||
init()
|
init()
|
||||||
# TODO: make these not global variables?
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
|
if len(sys.argv) > 1:
|
||||||
add_user(sys.argv[1], sys.argv[2], "TRUE")
|
add_user(sys.argv[1], sys.argv[2], "TRUE")
|
||||||
|
|
||||||
app.run(host='0.0.0.0', port=5000)
|
app.run(host='0.0.0.0', port=5000)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user