From be01a9ec1af5930505d77468af35aff3181700cf Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Wed, 17 Nov 2021 18:44:12 -0600 Subject: [PATCH 1/1] init commit --- README.md | 4 ++++ app.py | 40 ++++++++++++++++++++++++++++++++++++++++ requirements.txt | 13 +++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 README.md create mode 100644 app.py create mode 100644 requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..0bb9114 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Fuck emailing credentials + +pip install -r requirements.txt +python -m flask run --host 0.0.0.0 diff --git a/app.py b/app.py new file mode 100644 index 0000000..14eb7d3 --- /dev/null +++ b/app.py @@ -0,0 +1,40 @@ +import os +from flask import Flask, flash, request, redirect, url_for +from werkzeug.utils import secure_filename + +UPLOAD_FOLDER = "/tmp/" +ALLOWED_EXTENSIONS = {"txt", "pdf", "png", "jpg", "jpeg", "gif"} + +app = Flask(__name__) +app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER + + +def allowed_file(filename): + return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS + + +@app.route("/", methods=["GET", "POST"]) +def upload_file(): + if request.method == "POST": + # check if the post request has the file part + if "file" not in request.files: + return redirect(request.url) + file = request.files["file"] + # if user does not select file, browser also + # submit an empty part without filename + if file.filename == "": + return redirect(request.url) + if file and allowed_file(file.filename): + filename = secure_filename(file.filename) + file.save(os.path.join(app.config["UPLOAD_FOLDER"], filename)) + return redirect(url_for("uploaded_file", filename=filename)) + + return """ + + Upload new File +

Upload new File

+
+ + +
+""" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..40a30bb --- /dev/null +++ b/requirements.txt @@ -0,0 +1,13 @@ +black==21.11b0 +click==8.0.3 +Flask==2.0.2 +itsdangerous==2.0.1 +Jinja2==3.0.3 +MarkupSafe==2.0.1 +mypy-extensions==0.4.3 +pathspec==0.9.0 +platformdirs==2.4.0 +regex==2021.11.10 +tomli==1.2.2 +typing_extensions==4.0.0 +Werkzeug==2.0.2 -- 2.20.1