Currently, sending a postman request out to my API on my static-file-serving route gives me a 404 error, despite me double-checking that I'm GETting from the right route. The server worked fine in terms of serving files before adding SocketIO. Unfortunately, even when I remove the flask-socketio middleware, I cannot get the files to serve. Currently, I haven't touched this route in a long time, so I'm not sure what exactly happened.
Previously, I didn't have the static_url_path and static_folder options set when initiating the flask app object. I just added them after reading up on some other answers, but I get a 404 regardless of their presence.
All my other routes are working as intended.
UPLOAD_FOLDER = '/profile_pictures'
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
app = flask.Flask(__name__, static_url_path='/', static_folder="/profile_pictures")
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
UPLOAD_FOLDER = './profile_pictures'
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
#unrelated code
@app.route('/profile_pictures/<filename>', methods=['GET'])
@cross_origin(supports_credentials=True)
def get_profile_picture(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'],filename, as_attachment=True)
Any insight as to what the issue may be is greatly appreciated.
Ended up being I set the UPLOAD_FOLDER directory to
UPLOAD_FOLDER = '/profile_pictures'
Where it should've been
UPLOAD_FOLDER = 'profile_pictures'
Thanks for the answer @ Alexander : )