main.py: Try to upload to /tmp

Creating and uploading to an "uploads" directory works locally, but
on Google App Engine I get an HTTP 500. Let's try uploading to /tmp.
This commit is contained in:
Alan Orth 2021-03-11 16:06:33 +02:00
parent b3e66e1a8f
commit d204c23b93
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -6,7 +6,7 @@ from werkzeug.utils import secure_filename
app = Flask(__name__) app = Flask(__name__)
app.config["MAX_CONTENT_LENGTH"] = 1024 * 1024 app.config["MAX_CONTENT_LENGTH"] = 1024 * 1024
app.config["UPLOAD_EXTENSIONS"] = [".csv"] app.config["UPLOAD_EXTENSIONS"] = [".csv"]
app.config["UPLOAD_PATH"] = "uploads" app.config["UPLOAD_PATH"] = "/tmp"
@app.route("/") @app.route("/")
@ -24,12 +24,6 @@ def upload_file():
if file_ext not in app.config["UPLOAD_EXTENSIONS"]: if file_ext not in app.config["UPLOAD_EXTENSIONS"]:
abort(400) abort(400)
# make sure the upload directory exists
try:
os.mkdir(app.config["UPLOAD_PATH"])
except FileExistsError:
pass
uploaded_file.save(os.path.join(app.config["UPLOAD_PATH"], filename)) uploaded_file.save(os.path.join(app.config["UPLOAD_PATH"], filename))
return redirect(url_for("index")) return redirect(url_for("index"))