Question

Sorry if the question seems stupid. I'm currently trying to create a website using Flask. This website will let user entry with an images. Let's say there is a price, a title, a description and an image. My problem here is with the images. I can store all the information I need in the databse but I really don't know what to do about the images. For example, when people enter the website, I'd want to display a couple of those images.

BUT, where do I store them, how do I serve them when they are called ? (For example, if I look at a user profile I'd like to see his post, images, etc...) I just don't know what to do about those images. If someone could explain like i'm an idiot or link me some information about that.

(For example, when you look at someone's profil on instagram you'll see every on his images, that's what i'd like too achieve)

Thanks !

Was it helpful?

Solution

You could store the images on the filesystem of your web server, then configure your webserver to serve them statically (if using Apache, for example, this would be done via the Alias Directive).

This would involve mapping URLs (e.g. mysite.com/img/) to a directory on the web server's filesystem (e.g. /home/images). Of course, your webserver will most likely be serving a directory by default, for example /var/www/, and you could simply store the images here.

Where you store the images (and how they are served) will depend on things specific to your application, such as security (note that if you serve a particular directory on your filesystem, any client could potentially download the contents).

EDIT As per your comment - This would depend mostly on the size of the available storage on your web server. Also keep in mind that you should use images of a reasonable size, and a compressed format such as PNG or GIF.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top