Normally if we are using a save as feature this can means that you want to upload the file on the server (which in dev environment case is localhost). For this soul purpose we have some functionalities in Flask already.
For starters you have to setup the flask app and two routes, one for getting the filepath and then the second for getting the file and uploading it.
from flask import Flask, render_template, request
from werkzeug import secure_filename
app = Flask(__name__)
@app.route('/upload')
def upload_file():
return render_template('upload.html')
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
return 'file uploaded successfully'
This will be your upload.html file:
<html>
<body>
<form action = "http://localhost:5000/uploader" method = "POST"
enctype = "multipart/form-data">
<input type = "file" name = "file" />
<input type = "submit"/>
</form>
</body>
</html>
The default upload folder path and maximum size of uploaded files can be defined in the configuration settings for the Flask object.
Define the path to the upload folder
app.config['UPLOAD_FOLDER']
I believe this is what you were looking for.