Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Problems Loading Image

I'm following a tutorial and attempting to create a blog in Flask, trying to return a default image for users when they create their profile. Flask can't seem to find the image I need, even though the path to the file seems correct. It returns a 404 error, saying the file can't be found:

​

"GET /static/profile\_pics/default.jpeg HTTP/1.1" 404 -"

​

Yet that is the correct path, the path to the image is:

​

"PycharmProjects/flaskwebsite1/flaskblog/static/profile\_pics/default.jpeg"

​

It finds the css style sheet, also in "static" correctly, so I'm really not sure what the issue could be as to why it isn't finding the image.

​

Here are the relevant code snippets. Here's the route that uses the image:

@app.route("/account")
@login_required
def account():
#need to add an image file for the user
#image files to be stored in static directory
form = UpdateAccountForm()
image_file = url_for('static', filename='profile_pics/' + current_user.image_file)
return render_template('account.html', title='Account', image_file=image_file, form=form)

​

Image\_file references the user class in my [models.py](https://models.py) file:


class User(db.Model, UserMixin):


/r/flask
https://redd.it/9g4r1f